Parsing a text file, handling a new line?
<p>I'm trying to write a simple program which takes a textfile, sets all characters to lowercase and removes all punctuation. My problem is that when there is a carriage return (I believe that's what it is called) and a new line, the space is removed.</p>

<p>i.e.</p>

<blockquote>
  <p>This is a<br>
  test sentence</p>
</blockquote>

<p>Becomes</p>

<blockquote>
  <p>This is atestsentence</p>
</blockquote>

<p>The last word of the first line and the first word of the next line are joined.</p>

<p>This is my code:</p>

<pre><code>public static void ParseDocument(String FilePath, String title)
    {
        StreamReader reader = new StreamReader(FilePath);
        StreamWriter writer = new StreamWriter("C:/Users/Matt/Documents/"+title+".txt");

        int i;
        char previous=' ';
        while ((i = reader.Read())&gt;-1)
        {
            char c = Convert.ToChar(i);
            if (Char.IsLetter(c) | ((c==' ') &amp; reader.Peek()!=' ') | ((c==' ') &amp; (previous!=' ')))
            {
                c = Char.ToLower(c);
                writer.Write(c);                    
            }
            previous = c;

        }

        reader.Close();
        writer.Close();
    }
</code></pre>

<p>It's a simple problem, but I can't think of a way of checking for a new line to insert a space. Any help is greatly appreciated.</p>
