title: C# remove extra carriage returns from Stream
body: <p>Im reading file in as a stream: <code>Stream fin = File.OpenRead(FilePath);</code>
  Is there any way how i would be able to find and remove all carriage returns from that file stream?</p>
  
  <p>EDIT: The goal is to remove single carriage-returns <code>\r</code> and leave the carriage returns what are with newline <code>"\r\n"</code> intact.</p>
  
  <p>Example file:</p>
  
  <pre><code>The key backed up in this file is:\r
  \r\n
  pub   2048R/65079BB4 2011-08-01\r
  \r\n
        Key fingerprint = 2342334234\r
  \r\n
  uid                  test\r
  \r\n
  sub   2048R/0B917D1C 2011-08-01\r
  </code></pre>
  
  <p>And the result should look like:</p>
  
  <pre><code>The key backed up in this file is:
  \r\n
  pub   2048R/65079BB4 2011-08-01
  \r\n
        Key fingerprint = 2342334234
  \r\n
  uid                  test
  \r\n
  sub   2048R/0B917D1C 2011-08-01
  </code></pre>
  
  <p>EDIT2: The final solution what is working looks like this:</p>
  
  <pre><code>    static private Stream RemoveExtraCarriageReturns(Stream streamIn)
      {
          StreamReader reader = new StreamReader(streamIn);
          string key = reader.ReadToEnd();
          string final = key.Replace("\r\r", "\r");
          byte[] array = Encoding.ASCII.GetBytes(final);
          MemoryStream stream = new MemoryStream(array);
          return stream;
      }
  </code></pre>
  
  <p>I take in the <code>Stream</code> use <code>StreamReader</code> to read it into a string, then remove the extra carriage-return and write it back to a <code>Stream</code>.
  Does my code look ok or should i do something differently?</p>