title: Creating/writing into a new file in Qt
body: <p>I am trying to write into a file and if the file doesn't exist create it. I have searched on the internet and nothing worked for me.</p>
  
  <p>My code looks currently like this:</p>
  
  <pre><code>QString filename="Data.txt";
  QFile file( filename );
  if ( file.open(QIODevice::ReadWrite) )
  {
      QTextStream stream( &amp;file );
      stream &lt;&lt; "something" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>If I create a text file called Data in the directory, it remains empty. If I don't create anything it doesn't create the file either.
  I don't know what to do with this, this isn't the first way in which I tried to create/write into a file and none of the ways worked.</p>
  
  <p>Thanks for your answers.</p>