title: How can I get this buffered writer to write one line at a time? JAVA
body: <p>I am creating a little program that will amend driver letters saved in a program file. The method works in the sense that it locates the file correctly and amends the drive letter correctly. </p>
  
  <p>However when I open the file after it has been changed all the Directory listings are all on one line but they need to be 1 directory per line. I've tried saving each individual line to an Array List then printing them out like that but that didn't seem to work for me so was wondering if anyone could help? </p>
  
  <p>Much appreciated. </p>
  
  <p>P.S. Been messing around trying to make it work and also now ran into another issue where it is now printing them all out into one line but with spaces in between e.g: </p>
  
  <p>S:\ D A T A\ S A G E\ </p>
  
  <pre><code>public class copy
  {
  
  private String newDriveLetter;
  private String line;
  private Path[]sageFolders;
  private FileReader fileReader;
  private BufferedReader bufferedReader;
  private FileWriter fileWriter;
  private BufferedWriter bufferedWriter;
  private List&lt;String&gt; lines = new ArrayList&lt;String&gt;();
  
  
  
      public void scanFiles() throws IOException{
  
         try
         {
          System.out.println("Sage 2015 is Installed on this machine");
          File companyFile = new File(sageFolders[8] + "\\COMPANY");
          fileReader = new FileReader(companyFile);
          bufferedReader = new BufferedReader(fileReader); 
  
          while((line = bufferedReader.readLine()) != null)
          {
             if(line.contains("F"))
             {
                 line = line.replace("F:\\","S:\\");
                 lines.add(line);
  
             }
  
          }
          //Close the Readers
          fileReader.close();
          bufferedReader.close();
  
          fileWriter = new FileWriter(companyFile);
          bufferedWriter = new BufferedWriter(fileWriter);
  
          for(String s : lines)
          {
              bufferedWriter.write(s);
          }
  
          bufferedWriter.flush();
          bufferedWriter.close();
  
         }
         catch(FileNotFoundException e)
         {
            System.out.println("File not Found: Moving onto next Version"); 
         }
  
  }
  </code></pre>