title: java writing to a text file
body: <p>I would like the following to be printed</p>
  
  <p>test1</p>
  
  <p>test2</p>
  
  <p>test3</p>
  
  <p>test4    </p>
  
  <p>But I can't seem to get the text to the next line.</p>
  
  <p>Please help</p>
  
  <pre><code>import java.io.*;
  
  public class MainFrame {
      public static void main(String[] args) {
          try {
          BufferedWriter out = new BufferedWriter(new FileWriter("file.txt"));
              for (int i = 0; i &lt; 4; i++) {
                  out.write("test " + "\n");
              }
              out.close();
          } catch (IOException e) {}
      }
  }
  </code></pre>