public void writeToFile() {
    int[]scores = new int[5];
    String[]names = new String[5];
    String[]difficulties = new String[5];
    String diffString;
    if (difficulty == 0)
      diffString = "Easy";
    else if (difficulty == 1)
      diffString = "Medium";
    else
      diffString = "Hard";
    
    try {
      Scanner scan = new Scanner(new File("scores.txt"));
      for (int x = 0; x < 5; x++) {
        names[x] = scan.next();
        difficulties[x] = scan.next();
        scores[x] = scan.nextInt();
      }
      for (int x = 0; x < 5; x++) {
        if (scores[x] < score) {
          for (int y = x; y < 3; y++) {
            names[x+1] = names[x];
            difficulties[x+1] = difficulties[x];
            scores[x+1] = scores[x];
          }
          scores[x] = score;
          difficulties[x] = diffString;
          names[x] = name;
          break;
        }
      }
      PrintWriter print = new PrintWriter(new FileWriter("scores.txt"));
      for (int x = 0; x < 5; x++)
        print.println(names[x] + " " + difficulties[x] + " " + scores[x]);
      print.close();
    }
    catch(Exception e){
    }
  }