title: How can I output a new text file every time my program runs?
body: <p>I would like to know how I can make the program output a new text file every time it runs. For example first run machineslot(1).txt, second run machineslot(2).txt, and so forth. Or, make the output file contain when the file was made.</p>
  
  <pre><code>File file = new File("MachineSlot.Txt"); 
  
      try(PrintWriter out = new PrintWriter(new FileWriter(file));) {
  
          for (int i = 0; i &lt; winData.length; i++){ 
  
              if (winData[i][0] != 0.0) {
  
              out.printf("You won Machine %.0f. You won $%.2f. You have %.0f quarters which equals $%.2f %n", winData[i][0], winData[i][1], winData[i][2], winData[i][3]);
  
              }
          }
  
          for (int k = 0; k &lt; plays.length; k++)
              out.println("You were able to play machine " + (k + 1) +" a total of "+ plays[k] + " times.");
      }//end of try.      
  
      catch(IOException error){
          System.out.println("Could not use the IO file");
      }//End catch
  </code></pre>