public static void main(String[] args) {
        String line;
        BufferedWriter bufferedWriter = null;
//        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in))) {
        try (BufferedReader bufferedReader = new BufferedReader(new FileReader(inputFilePath))) {
            bufferedWriter = new BufferedWriter(new FileWriter(outputFilePath));

            line = bufferedReader.readLine(); //read T, numberOfTestCases
            int numberOfTestCases = Integer.parseInt(line);

            if(!checkNumberOfTestCases(numberOfTestCases)){
                //invalid number of test cases
                System.out.println("Invalid number of test cases entered. Program exiting.");
                return;
            }

            for (int testCaseIndex = 1; testCaseIndex <= numberOfTestCases; testCaseIndex++) {
                TestCase testCase = new TestCase(bufferedReader);
                PerformanceResult performanceResult = testCase.solve();
                StringBuilder sb = new StringBuilder();
                sb.append("Case #");
                sb.append(testCaseIndex);
                sb.append(": ");
                if (performanceResult.getMagicianJobPerformance() == MagicianJobPerformance.GOOD) {
                    sb.append(performanceResult.getCardList().get(0).getValue());
                } else {
                    sb.append(performanceResult.getMagicianJobPerformance().getMessage());
                }
//                System.out.println(sb);
                bufferedWriter.write(sb.toString());
                bufferedWriter.newLine();
            }
        } catch (Exception e) {
            System.out.println("Exception when using reader.");
            e.printStackTrace();
        } finally {
            if (bufferedWriter != null) {
                try {
                    bufferedWriter.flush();
                    bufferedWriter.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }