title: Using ofstream for buffered text output to gain performance
body: <p>I need to write a program which will write many characters in a output file.
  My program will also need to write newline for better formatting.
  I understand <code>ofstream</code> is a buffered stream and if we use a buffered stream for file io, we gain performance. However, if we use <code>std::endl</code> the output will be flushed and we will loose any potential performance gain due to the buffered output.</p>
  
  <p>I suppose if I use <code>'\n'</code> for new line the output will be only flushed when we will <code>std::endl</code>. Is this correct? And are there any tricks that can be used to get performance gain during file output?</p>
  
  <p>Note: I want to flush the buffered output at the completion of the file write operations. I think in this way I can minimize file I/O and thus can gain performance.</p>