title: Weird behavior with ifstreams and rdbuf()
body: <p>I've noticed that using <code>.rdbuf()</code> on an <code>ifstream</code> seems to change it somehow. The following code should show the problem.</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main(int argc, const char * argv[]) {
      ifstream ifs("Sample.csv");
      cout &lt;&lt; "Reading buffer: " &lt;&lt; endl;
      cout &lt;&lt; ifs.rdbuf(); // Outputs buffer as expected
      cout &lt;&lt; "Reading buffer again: " &lt;&lt; endl;
      cout &lt;&lt; ifs.rdbuf(); // Returns nothing
  
      return 0;
  }
  </code></pre>
  
  <p>The reason this is bothering me is that I'm currently trying to copy the contents of one text file into another using <code>ofstream ofs; ofs &lt;&lt; ifs.rdbuf()</code>. This works fine but makes reading from <code>ifs</code> using <code>getline(ifs, str)</code> fail, effectively "breaking" the stream. </p>