How do I create a text file and write data to it in javascript?

Hi all,

I need to write some data (just numbers and strings) to a text file that I can access once the game has stopped running. My ‘game’ is collecting data that is going to be used later in a different program, so player prefs isn’t really an option (I think).

I’m using javascript, and I haven’t been able to figure out how to create a new txt file, or even how to write to an already existing txt file. I have all my other code working; I just need a way to create a new txt file and then write or append strings to it.

I’ve been thinking that maybe some kind of File.IO command would do the trick, but nothing that I’ve tried seems to work so far.

sw = new StreamWriter(“name of file.txt”);
sw.Write("write you want: ");
sw.WriteLine(item.name); //write and then give enter
sw.Write("write you want: ");
sw.WriteLine(Time.time); //If you want to save a variable
sw.Close(); //Close the file