title: Writing Multiple Lines to a File (.txt) in Java
body: <p>I am new to File Streams and would appreciate some help. The following code is the code I use to write to a specified file.</p>
  
  <pre><code>OutputStream outStream = new FileOutputStream(file);
  outStream.write(contentsToWrite.getBytes());
  outStream.close();
  </code></pre>
  
  <ol>
  <li>How do I save different lines to a file? In my case using <code>\n</code> does not work when writing to a file.</li>
  <li>How do I save a line to the file without deleting the other lines?</li>
  </ol>