title: C# Read text file line by line and edit specific line
body: <p>I want to read a text file line by line and edit a specific line. So, I have put the text file into a string variable like:</p>
  
  <p><code>string textFile = File.ReadAllText(filename);</code></p>
  
  <p>My text file is like:</p>
  
  <pre><code>Line A
  Line B
  Line C
  Line abc
  Line 1
  Line 2
  Line 3
  </code></pre>
  
  <p>I have a specific string (="abc"), which I want to search in this textFile. So, I am reading the lines until find the string and going to the third line ("Line 3" -> this line is always different) after that found string:</p>
  
  <pre><code>string line = "";
  string stringToSearch = "abc";
  
  using (StringReader reader = new StringReader(textFile))
  {
      while ((line = reader.ReadLine()) != null)
      {
          if (line.Contains(stringToSearch))
          {
              line = reader.ReadLine();
              line = reader.ReadLine();
              line = reader.ReadLine();
  
              //line should be cleared and put another string to this line.
          }
      }
  }
  </code></pre>
  
  <p>I want to clear the third read line and put another string to this line and save the whole <code>string</code> into <code>textFile</code>.</p>
  
  <p>How can I do this? </p>