title: How to read a CSV file one line at a time and parse out keywords
body: <p>I am new to C# and I have started using <code>StreamReader</code>. I am trying to read a file one line at a time and output the line when it matches a specific keyword like "I/RPTGEN".</p>
  
  <p>So far I figured out how to read the entire file into a string, but I'm having trouble figuring out how to just read it one line at a time.  </p>
  
  <p>My code so far is this.</p>
  
  <pre><code>using System;
  using System.IO;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace ConsoleApplication5
  {
  class Test
  {
      public static void Main()
      {
          try
          {
              using (StreamReader sr = new StreamReader("c:/temp/ESMDLOG.csv"))
              {
                  String line = sr.ReadToEnd();
                  Console.WriteLine(line);
  
                  Console.ReadLine();
              }
          }
          catch (Exception e)
          {
              Console.WriteLine("The File could not be read:");
              Console.WriteLine(e.Message);
  
              Console.ReadLine();
          }
      }
  }
  }
  </code></pre>
  
  <p>Plus here is a sample of one line in the file. </p>
  
  <blockquote>
    <p>Advisory,2/27/2013 12:00:44 AM,I/RPTGEN (cadinterface),I/RPTGEN Failed - Error 500 - Internal Server Error  - returned for a report request (check log for URL).</p>
  </blockquote>