PrintWriter failing to print to file
<p>The file is being created successfully, but I cannot get PrintWriter to print anything to the text file. Code: </p>

<pre><code>import java.io.File;
import java.util.Scanner;
import java.io.IOException;
import java.io.PrintWriter;

public class exams {
    public static void main (String[] args) throws IOException{
        Scanner scanner = new Scanner(System.in);
        System.out.println("How many scores were there?");
        int numScores = scanner.nextInt();
        int arr[] = new int[numScores];

        for (int x=0; x&lt;numScores; x++){
            System.out.println("Enter score #" + (x+1));
            arr[x] = scanner.nextInt();
        }

        File file = new File("ExamScores.txt");
        if(!file.exists()){
           file.createNewFile();
           PrintWriter out = new PrintWriter(file);
            for (int y=0; y&lt;arr.length; y++){
                out.println(arr[y]);
            }
        }
        else {
            System.out.println("The file ExamScores.txt already exists.");
        }   
    }
}
</code></pre>
