I am having trouble seeing what is causing my error. Code is below and below that is the error message I am receiving. Thank you.
import java.util.*;
import java.io.*;
public class IO {
public static void main(String[] args) throws Exception {
    File inFile = new File("src/passign6/grades.txt");
    File outFile = new File("src/passign6/finalgrades.txt");
    try (
            Scanner input = new Scanner(inFile);
            PrintWriter output = new PrintWriter(outFile);) {
        int[][] grades = new int[42][];
        for (int i = 0; input.hasNextLine() && i < grades.length; i++) {
            String line = input.nextLine();
            Scanner input2 = new Scanner(line);
            for (int j = 0; input2.hasNextInt() && j < grades[i].length; j++) {
                grades[i][j] = input.nextInt();
            }
            input.close();
            output.close();
        }
    }
}
}
Exception in thread "main" java.lang.NullPointerException
at io.IO.main(IO.java:20)
 
    