title: File input/output
body: <p>Ive been asked my current program to be saved into a file so it can be continued later even if the program end. However I am new to java, so I Would really appreciate if someone can help me on this :) This is the code i manage to get done, however it just creates an empty file,how am I suppose to go about this problem?</p>
  
  <p>Below is not the whole program coding, i've just copied the codes that is relevant. </p>
  
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.PrintWriter;
  import java.io.FileWriter;
  
  
  public static void main (String[] param) throws FileNotFoundException
  {
   try 
      {
      fileinputoutput ();
      } 
      catch (FileNotFoundException e) 
      {
     System.exit(0);
      }
  } // END main
  
  
  
  public static void fileinputoutput() throws FileNotFoundException
   {
  
      File input = new File("input.txt");
      File output = new File("loveletter.txt");
      PrintWriter outputFile = new PrintWriter(output);
  
      Scanner check = new Scanner(System.in);
  
      String filename = check.nextLine();
      File inputfile = new File(filename);
  
      Scanner newfile = new Scanner(inputfile);
      newfile.close();
  
      while(newfile.hasNext())
      {
  
      String write = newfile.nextLine();
      System.out.println(write);
  
      }
  
      outputFile.close();
  
  }
  </code></pre>