How to Display each name Last line from a text file
<p>I want to display the last line of each name.  There are many names in a text file, the one name contains more than 50 lines.  I want to display each name last line from a text file.</p>

<p>please check this link you all will get idea.</p>

<p><img src="http://i.stack.imgur.com/MTt5D.png"></p>

<p>there are names such as butter and apple.  butter contains 9 lines and apple contains apple contains 22 lines.  I want to Display the 9th line of the butter and 22nd line in apple</p>

<p>Thanks In Advance.</p>

<p>I am using  this code  to display all lines , but I want to Display the 9th line of the butter and 22nd line in apple.</p>

<pre><code>static void Main(string[] args)
{
    int counter = 0;
    string line;

    // Read the file and display it line by line. 
    System.IO.StreamReader file = new System.IO.StreamReader("c:\\tra\\20100901.txt");
    while ((line = file.ReadLine()) != null)
    {
        if (line.Contains("apple"))
        {
            Console.WriteLine(counter.ToString() + ": " + line);
        }

        counter++;
    }

    file.Close();  
}
</code></pre>
