public void addHistory(String date, String name1, String name2, String score, String duration) throws IOException {
        // Add a new record to the top of the log
        String savedGame = date + "," + name1 + "," + name2 + "," + score + "," + duration;
        String temp = "temp-history.csv";
        String p = null;
        BufferedReader br = null;
        InputStream is = null;
        InputStreamReader isr = null;
        BufferedWriter bw = null;
        
        try {
            // Create temp file to combine old data with new record
            if(historyFile.exists()){
                // Read History log from generated file
                
                br = new BufferedReader(new FileReader(historyFile));
            }
            else{
                // Read History log from internal file
                
                is = getClass().getResourceAsStream("/" + csvFileName);
                isr = new InputStreamReader(is);
                br = new BufferedReader(isr);
            }
            
            bw = new BufferedWriter(new FileWriter(tempFile));
            bw.write(savedGame);
            bw.newLine();
            while ((p = br.readLine()) != null ){
                bw.write(p);
                bw.newLine();
            }
            br.close();
            bw.close();

            // Overwrite old file with temp file contents
//            is = getClass().getResourceAsStream("/" + temp);
//            isr = new InputStreamReader(is);
//            br = new BufferedReader(isr);
//            System.out.println(new File("").getAbsolutePath() + "/res");
            
            br = new BufferedReader(new FileReader(tempFile));
            bw = new BufferedWriter(new FileWriter(historyFile));
            p = null;
            while ((p = br.readLine()) != null ){
                bw.write(p);
                bw.newLine();
            }
            br.close();
            bw.close();
        } 
        catch (FileNotFoundException e) {
            e.printStackTrace();
        } 
        catch (IOException e) {
            e.printStackTrace();
        } 
        finally {
            if (br != null) {
                try {
                    br.close();
                } 
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }   
        // Reload the history data into memory
        loadHistory();
    }