Read line "x" from .txt file

Hello,

I have recently decided to implement a save function to my game, I am new to this whole area so bare with me.

I have adopted some code I found online for loading, it looks like this:

function fileLoad ()
{
    try
	{
        // Create an instance of StreamReader to read from a file.
        sr = new StreamReader("TestFile.txt");
        // Read and display lines from the file until the end of the file is reached.
        line = sr.ReadLine();
        while (line != null)
		{
            print(line);
            line = sr.ReadLine();
        }
        sr.Close();
    }
    catch (e)
	{
        // Let the user know what went wrong.
        print("The file could not be read:");
        print(e.Message);
    }
}

My question is, how can I get the line number of the file that is being read (ex. line 146 = playerDamage).

Any help is appreciated!

You can load the whole text file and use

textArray = text.Split("\n"[0]);

to store the text as a String Array.

Then access each line with

textArray[146]

or similar

Thank you so much, I will try this when I get home.

Works great thanks.