title: StreamReader not working as expected
body: <p>I have written a simple utility that loops through all C# files in my project and updates the copyright text at the top.</p>
  
  <p>For example, a file may look like this;</p>
  
  <pre><code>//Copyright My Company, © 2009-2010
  </code></pre>
  
  <p>The program should update the text to look like this;</p>
  
  <pre><code>//Copyright My Company, © 2009-2010
  </code></pre>
  
  <p>However, the code I have written results in this;</p>
  
  <pre><code>//Copyright My Company, ï¿½ 2009-2011
  </code></pre>
  
  <p>Here is the code I am using;</p>
  
  <pre><code>public bool ModifyFile(string filePath, List&lt;string&gt; targetText, string replacementText)
  {
      if (!File.Exists(filePath)) return false;
      if (targetText == null || targetText.Count == 0) return false;
      if (string.IsNullOrEmpty(replacementText)) return false;
  
      string modifiedFileContent = string.Empty;
      bool hasContentChanged = false;
  
      //Read in the file content
      using (StreamReader reader = File.OpenText(filePath))
      {
          string file = reader.ReadToEnd();
  
          //Replace any target text with the replacement text
          foreach (string text in targetText)
              modifiedFileContent = file.Replace(text, replacementText);
  
          if (!file.Equals(modifiedFileContent))
              hasContentChanged = true;
      }
  
      //If we haven't modified the file, dont bother saving it
      if (!hasContentChanged) return false;
  
      //Write the modifications back to the file
      using (StreamWriter writer = new StreamWriter(filePath))
      {
          writer.Write(modifiedFileContent);
      }
  
      return true;
  }
  </code></pre>
  
  <p>Any help/suggestions are appreciated. Thanks!</p>