title: Writing to QTextStream
body: <p>My QTextStream is empty when this code finishes:</p>
  
  <pre><code>QString line1 = "This is line one";
  QString line2 = "This is line two";
  QString line3 = "This is line three";
  
  QString outputFilename = "temp.txt";
  QFile outputFile(outputFilename);
  outputFile.open(QIODevice::WriteOnly);
  outputFile.open(QIODevice::ReadWrite);  // This fixes the problem
    QTextStream out1(&amp;outputFile);
     out1  &lt;&lt; line1 &lt;&lt; endl;
     out1  &lt;&lt; line2 &lt;&lt; endl;
     out1  &lt;&lt; line3 &lt;&lt; endl;
  
  outputFile.flush();
  QString temp = out1.readAll();           
  mainclipboard-&gt;setText(temp);
  outputFile.close();
  </code></pre>
  
  <p>Here, the QString temp is empty.  What have I missed?</p>
  
  <p>Thanks to hyde for the answer.</p>