title: Cannot write to csv file using BufferedWriter
body: <p>I am trying to append a row at the end of my csv file using the code below</p>
  
  <pre><code>public class Register {
  public static void add(int k,int m,int id1) throws Exception
  
  {
  
      ClassLoader classLoader = Register.class.getClassLoader();
  
      try{
          FileWriter fw = new FileWriter(new File(classLoader.getResource("data/dataset.csv").getFile()),true);
          BufferedWriter bw = new BufferedWriter(fw);
          bw.append("\n");
          bw.append(String.valueOf(id1));
          bw.append(',');
          bw.append(String.valueOf(m));
          bw.append(',');
          bw.append(String.valueOf(k));
          bw.close();
  
  
  
        }catch(IOException ioe){
           System.out.println("Exception occurred:");
           ioe.printStackTrace();
         }
  
      }
   }
  </code></pre>
  
  <p>I am calling this class from a servlet using a loop as I need to add 5 lines to my csv. Everything runs fine, but nothing gets added to the csv file. Please help.</p>