title: WriteAllText method returns the last row, instead of the entire rows of the file
body: <p>I have a code that:</p>
  <ul>
  <li>reads a text file,</li>
  <li>replaces all &quot;spaces&quot; with &quot;;&quot;,</li>
  <li>removes the repetition of the character &quot;;&quot;</li>
  <li>and saves a new file with all changes.</li>
  </ul>
  <p>But instead of writing all the rows in the file, it writes only the last row.</p>
  <pre><code>static void Main(string[] args)
      {
          RegexOptions options = RegexOptions.None;
          Regex regex = new Regex(&quot;[ ]{2,}&quot;, options);
          
          string FilePath = @&quot;C:\Users\User\Desktop\download1.txt&quot;;
          string OutputhFilePath = @&quot;C:\Users\User\Desktop\download2.txt&quot;;
  
          List&lt;string&gt; lines = new List&lt;string&gt;();
          lines = File.ReadAllLines(FilePath).ToList();
          
          foreach (string line in lines)
          {
              string line1 =  line.Replace(' ', ';');
              line1 = regex.Replace(line, &quot;;&quot;);
              Console.WriteLine(line1);
              File.WriteAllText(OutputhFilePath, line1);
          }
          
              Console.ReadLine();
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/5C7Gh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5C7Gh.png" alt="Text file:" /></a></p>
  <p><a href="https://i.stack.imgur.com/NKPwL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NKPwL.png" alt="Text file after code:" /></a></p>
  <p>Can someone help me with these? Thanks in advance!</p>