title: Boost String Replace Doesn't Replace Newline With String
body: <p>I am creating a function for my libspellcheck spell checking library that checks the spelling of a file. It's function is to read a text file and send its contents to the spell checking function. In order to have the spellchecking function process the text correctly, all newlines must be replaced with a space. I decided to use boost for this. Here is my function:</p>
  
  <pre><code>spelling check_spelling_file(char *filename, char *dict,  string sepChar)
  {
  
      string line;
      string fileContents = "";
      ifstream fileCheck (filename);
      if (fileCheck.is_open())
      {
          while (fileCheck.good())
              {
                  getline (fileCheck,line);
              fileContents = fileContents + line;
          }
  
          fileCheck.close();
      }
      else
      {
          throw 1;
      }
  
      boost::replace_all(fileContents, "\r\n", " ");
      boost::replace_all(fileContents, "\n", " ");
  
      cout &lt;&lt; fileContents;
  
      spelling s;
      s = check_spelling_string(dict, fileContents, sepChar);
  
      return s;
  }
  </code></pre>
  
  <p>After compiling the library, I created a test application, with a sample file.</p>
  
  <p>Test application code:</p>
  
  <pre><code>#include "spellcheck.h"
  
  using namespace std;
  
  int main(void)
  {
      spelling s;
      s = check_spelling_file("test", "english.dict",  "\n");
  
      cout &lt;&lt; "Misspelled words:" &lt;&lt; endl &lt;&lt; endl;
      cout &lt;&lt; s.badList;
      cout &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Test file:</p>
  
  <pre><code>This is a tst of the new featurs in this library.
  I wonder, iz this spelled correcty.
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>This is a tst of the new featurs in this library.I wonder, iz this spelled correcty.Misspelled words:
  
  This
  a
  tst
  featurs
  libraryI
  iz
  correcty
  </code></pre>
  
  <p>As you can see, the newlines are not being replaced. What am I doing wrong?</p>