How do I write a line of text to a file?

How do I write a line (or four) to a text file? I've looked all over the place but everything I can find is either in C# or is too specific. The documentation has next to nil on the subject.

What I'm trying to do is to take the output of four separate text boxes that specify the stats for an enemy and write them into a file. Then, I'd like to load the stats for that enemy at a later point. How can I do this?

Thanks in advance - Elliot B.


EDIT: I'd like the output to look like this:

`Troll 14 5 5 50`

I won't go into the specifics, but I need the name, strength, health, and whatnot. I'd also like to be able to read that back in. NOTE: This is not a 'write-my-code' problem. I've seen the warm welcome those receive and would not like to be facing the business end of some of my own comments. I just need a way to do it, because I can't find any documentation. Thanks again.


EDIT 2: I guess I'd better go ahead and explain what I'm trying to do. Okay. So, I've been playing some paper RPG games, and thought it would be cool if I could create a sort of 'fighting calculator'. So I went ahead and made one. Then I thought: "What if I could make it so the user could create his own monsters instead of me hardcoding each one?" Which looks like:

if (enemyName == "Common Orc") {
    ea1 = 5;
    ea2 = 6;
    enemyDefense = 8;
    enemyHealth = 35;
}

For each enemy. So I'm working on a way to get the player input for when he hits 'create new monster' and then types in the variables for it. My program would, theoretically, write the variables to a file, and then read them out again if I needed to use (fight) that monster. Does that make sense?

That's why I don't know if PlayerPrefs would work for this. Would it?

You can use System.IO.File.WriteAllText(filePath, yourString); ( http://msdn.microsoft.com/en-us/library/system.io.file.writealltext.aspx ) but honestly I'd stay clear of file IO unless you have to

Edit - you'll more likely want AppendAllText instead of WriteAllText if you're going to be adding them

Specific to your question:

System.IO.File.AppendAllText(yourPath, System.String.Format("{0} {1} {2} {3} {4}", enemyName, ea1, ea2, enemyDefense, enemyHealth));

I belierve theres JS specific info about this here

http://forum.unity3d.com/viewtopic.php?t=15313

I was also facing some problem with this streamwriter. But I fixed and succeed to include in my project. I have written a very post on this on my blog which may be useful for newbie.
http://bikramkawan.com.np/solved-write-to-text-files-with-c-in-unity3d-using-streamwriter/

works to edit single lines using system io.

function lineChanger( newText: String, fileName :String, line_to_edit: int)
{

        var arrLine : String[] = File.ReadAllLines(fileName);
        arrLine[line_to_edit - 1] = newText;
        File.WriteAllLines(fileName, arrLine);

}