title: Cross-platform newline confusion
body: <p>For some reason, my write-to-textfile function stopped working all of a sudden.</p>
  
  <pre><code>void write_data(char* filename, char* writethis)
  {
      ofstream myfile;
      myfile.open (filename, std::ios_base::app);
      myfile &lt;&lt; endl &lt;&lt; writethis;
      myfile.close();
  }
  </code></pre>
  
  <p>The function was called from a loop, so basically it started with an empty line and appended all the following "writethis" lines on a new line.</p>
  
  <p>Then all of a sudden, no more newlines. All text was appended on one single line. So I did some digging and I came across this:</p>
  
  <ol>
  <li>Windows = CR LF</li>
  <li>Linux = LF</li>
  <li>MAC &lt; 0SX = CR</li>
  </ol>
  
  <p>So I changed the line to</p>
  
  <pre><code>myfile &lt;&lt; "\r\n" &lt;&lt; writethis;
  </code></pre>
  
  <p>And it worked again. But now I'm confused. I am coding on <strong>linux</strong> but I am reading the textfiles created with the program out on <strong>windows</strong> after transferring them with <strong>filezilla</strong>. Now which part of this caused the lines in the textfile to appear as one line?</p>
  
  <p>I was pretty sure "endl" worked just fine for linux so now I'm thinking windows messed the file up <strong>after</strong> transferring them with filezilla? Messing up the way the text file is written to (and read out) will guarantee my program to break, so if someone can explain this I'd appreciate it.</p>
  
  <p>I also don't recall what I changed in my program to cause this to break, because it was working just fine earlier. The only thing I added was threading.</p>
  
  <p><strong>Edit:</strong>
  I have tried swapping the transfer mode from ASCII / Binary (even removed the force-ASCII-for-txt-extension), but it makes no differences. The newlines appear in linux, but not on windows.
  <img src="https://i.stack.imgur.com/9ubD8.png" alt="fz-messup"></p>
  
  <p>How odd.</p>