title: Writing an array to a file in Java
body: <p>Hi i've looked at all the other questions similar to this that I could find and haven't been able to fix my last problem, though the answers to other questions got me this far.</p>
  
  <p>I'm trying to write an array to a file, and so far I can do that, but the writer just writes everything on the same line. For some reason it won't accept my new line command (\n) when viewed in notepad.</p>
  
  <p>An example to try and explain:</p>
  
  <p>Array contents: test, test2, test3, test4</p>
  
  <p>Write to file</p>
  
  <p>File contents: test test2 test3 test4</p>
  
  <p>Whereas i want the file to be: 
  test
  test2
  test3
  test4</p>
  
  <p>Below is the segment of my code to write to the file.</p>
  
  <pre><code>    public void save(String fileName) throws FileNotFoundException {
  
      try {
  
          BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
          for ( int i = 0; i &lt; nbrMovies; i++)
          {      
          writer.write(movies[i].getName() + " \n");
          }
          writer.close();
      } catch(IOException ex) {
          ex.printStackTrace();
      }
  }
  </code></pre>
  
  <p>The file doesn't accept the "\n" command and instead just puts a little box next to the last movie added.</p>
  
  <p>Any and all help would be greatly appreciated.</p>