title: Java FileWriter how to write to next Line
body: <p>I used the code below to write record into a File. The record can be written in the file, but is append in one Line, each time  I call this method example:</p>
  
  <p>Hello WorldHello WorldHello WorldHello World</p>
  
  <p>How can I modify the code so the output look like below, so that when read the text I can use line.hasNextLine() to check?</p>
  
  <p>Hello World<br>
  Hello World<br>
  Hello World<br>
  Hello World</p>
  
  <pre><code>        // Create file
          FileWriter fstream = new FileWriter(fileName, true);
          BufferedWriter out = new BufferedWriter(fstream);
          out.write(c.toString());
          //Close the output stream
          out.close();
  
          // Code I used to read record I am using | as a seperator name and id
          String fileName = folderPath + "listCatalogue.txt";
          String line = "";
          Scanner scanner;
          String name, id;
          scanner = new Scanner(fileName);
          System.out.println(scanner.hasNextLine());
          while (scanner.hasNextLine()) {
              line = scanner.nextLine();
              System.out.println(line);
              StringTokenizer st = new StringTokenizer(line, "|");
              name = st.nextToken();
              id = st.nextToken();
              catalogues.add(new Catalogue(name, id));
          }
  </code></pre>