title: Searching for a Specific Word in a Text File and Displaying the line its on
body: <p>I am having trouble attempting to find words in a text file in C#.</p>
  
  <p>I want to find the word that is input into the console then display the entire line that the word was found on <em>in</em> the console.</p>
  
  <p>In my text file I have:</p>
  
  <p><strong>Stephen Haren,December,9,4055551235</strong></p>
  
  <p><strong>Laura Clausing,January,23,4054447788</strong></p>
  
  <p><strong>William Connor,December,13,123456789</strong></p>
  
  <p><strong>Kara Marie,October,23,1593574862</strong></p>
  
  <p><strong>Audrey Carrit,January,16,1684527548</strong></p>
  
  <p><strong>Sebastian Baker,October,23,9184569876</strong></p>
  
  <p>So if I input "December" I want it to display "Stephen Haren,December,9,4055551235" and "William Connor,December,13,123456789" .</p>
  
  <p>I thought about using substrings but I figured there had to be a simpler way.</p>
  
  <p>My Code After Given Answer:</p>
  
  <pre><code>using System;
  using System.IO;
  class ReadFriendRecords
  {
      public static void Main()
      {
          //the path of the file
          FileStream inFile = new FileStream(@"H:\C#\Chapter.14\FriendInfo.txt", FileMode.Open, FileAccess.Read);
          StreamReader reader = new StreamReader(inFile);
          string record;
          string input;
          Console.Write("Enter Friend's Birth Month &gt;&gt; ");
          input = Console.ReadLine();
          try
          {
              //the program reads the record and displays it on the screen
              record = reader.ReadLine();
              while (record != null)
              {
                  if (record.Contains(input))
                  {
                      Console.WriteLine(record);
                  }
                      record = reader.ReadLine();
              }
          }
          finally
          {
              //after the record is done being read, the progam closes
              reader.Close();
              inFile.Close();
          }
          Console.ReadLine();
      }
  }
  </code></pre>