title: Problems writing to a text file
body: <p>I'm trying to write a report to a text file. When I use the <code>print</code> method everything appears okay but in the file nothing is written. Here is my code.</p>
  
  <pre><code>public void writeFile(String filename,String report){
      try{
          FileWriter fw=null;
          try{
              fw = new FileWriter(filename);
              fw.write("The game report \n");
              fw.write(report);
              fw.write("Hope everyone has enjoyed it");
              fw.flush();
          }
          catch(FileNotFoundException e){
              System.out.println(filename +"not found");
              System.exit(0);
          }
          finally{
              try{
                  fw.close();
              }
              catch( Exception exp){
                  System.out.println("Problem closing the filewriter");
              }
          }
      }
      catch(IOException e) {
          e.printStackTrace();
          System.exit(1);
      }   
  }
  </code></pre>
  
  <p>And here is the code from the main method.</p>
  
  <pre><code>public class MainDarts {
      public static void main(String[] args) {
          GameManager manager = new GameManager();
          manager.readFile("Data.csv");
          manager.Execute();
          String report = manager.getOverallReport();
          manager.writeFile("OutputData.txt", report);
  
      }
  }
  </code></pre>