title: How do I keep java program running (loop) so I can use the scanner to input to the same text file text file?
body: <p>I am trying to use the java scanner input to read multiple inputs (numbers as a string eg. 12345) from keyboard and send to a text file, I have a scanner reading input.nextLine(), where it will read in each line. I just would like to run my program and have it stay running so it will populate the text file with each scanner input. I am using the following code:</p>
  
  <pre><code>import java.util.*;
  import java.io.*;
  
  public class tap1 
  {    
      public static void main(String[] args) throws IOException
      {
          System.out.println("Please enter number:");     
          File outFile = new File ("CardNumbers.txt");
          FileWriter fWriter = new FileWriter (outFile, true);
          PrintWriter pWriter = new PrintWriter (fWriter);
          Scanner scan = new Scanner(System.in);
          String num = scan.nextLine();
          pWriter.println (num);
          pWriter.close();                
      }   
  }
  </code></pre>