title: QT, Write in new line in a file
body: <p>I have written a code to read from line_Edit in GUI, and write in a file. The code reads the text from line edit and writes the same in the file, but they are printed continuously without any spaces, I want to print the texts written in the line edit in different lines. The file has written text, just want to replace first word of each line by the user entered words.</p>
  
  <p>Code to write in the file:</p>
  
  <pre><code>void MainWindow::on_write_btn_clicked(){
      QString str, str2, lin;
      str = ui-&gt;lineEdit-&gt;text();
      str2 = ui-&gt;lineEdit2-&gt;text();
      QFile file1("sample.txt");
      if(file1.open(QIODevice::ReadWrite | QIODevice::Text)){
          QTextStream out(&amp;file1);
          out &lt;&lt; str;
          lin = out.readLine();
          out &lt;&lt; str2;
          file1.seek(30);
          file1.close();
      }
      else
          return;
  }
  </code></pre>
  
  <p>File in which we want to write:
  <a href="https://i.stack.imgur.com/4PkWp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4PkWp.png" alt="file in which we want to write"></a></p>