public static void getBest(int id, BufferedWriter writer) {
    Integer bid = new Integer(-1);
    Integer sid = new Integer(-1);
    Integer tid = new Integer(-1);
    Double dmin = new Double(9999);
    int indx = -1;
    for (int i=0; i<Scores.size(); i++) {
      if (Scores.get(i) < dmin) {
        dmin = Scores.get(i);
        bid = IDs.get(i);
        indx = i;
        //System.out.println(dmin);
      }
    }
    dmin = new Double(9999);
    Scores.remove(indx);
    IDs.remove(indx);

    for (int i=0; i<Scores.size(); i++) {
      if (Scores.get(i) < dmin){
        dmin = Scores.get(i);
        sid = IDs.get(i);
        indx = i;
      }
    }
    dmin = new Double(9999);
    Scores.remove(indx);
    IDs.remove(indx);

    for (int i=0; i<Scores.size(); i++) {
      if (Scores.get(i) < dmin){
        dmin = Scores.get(i);
        tid = IDs.get(i);
        indx = i;
      }
    }
    String output = new Integer(id).toString().concat(" ")
      .concat(bid.toString()).concat(" ").concat(sid.toString()).concat(" ").concat(tid.toString().concat("\n"));
    //System.out.println("The top similarities to " + id + " are " + bid + " " + sid + " " + tid);
    
    try {
      writer.write(output);
    } catch (Exception e) {
      e.getMessage();
    }
    IDs.clear();
    Scores.clear();
  }