title: Modify a specific line in a text file
body: <p>is someone knows how I may replace a line in a txt file? 
  For exemple i have 10 lines in the file and I want to replace the line[4]. 
  I actually have this code:</p>
  
  <pre><code>string old = "old string";
  string nw =" new string";
  int counter = 0;
  
  foreach(string s in File.ReadLines(path))
  {
      if (s = old) 
      {
          //replace the line[counter] of the text file 
      } 
      counter ++;
  }
  </code></pre>
  
  <hr>
  
  <p>I know I can make a StringCollection and add each lines in the StringCollection indexes and replace only the index that contains the string to replace and overwrite the text file but it may sometimes needs a lot of resources. </p>
  
  <p>Thanks in advance for your help. </p>