'Why the checkID() function is using bufferReader not a bufferWriter in here?

This is an airline reservation system, so this is the class of the traveler. In this class, we have the function of signing up if the user didn't have an account already. However, in this example, it is using a buffered reader that checks the id of the traveler who is still signing up. isn't it supposed to use buffer writer to write the traveler's ID into the CSV file? Please correct me and explain it in deep detail. thanks!

public  void signUp(String filepath) throws IOException {
    int check = 0;
    String path = filepath;
    FileWriter fw = new FileWriter(path, true);
    BufferedWriter br = new BufferedWriter(fw);
    PrintWriter pw = new PrintWriter(br);
    
    Scanner i = new Scanner(System.in);
    
    System.out.println("Enter your name");
    String name = i.next();
    
    System.out.println("Enter your password");
    String password = i.next();

    int travellerID = (int)(Math.random()*90000 + 100000);

    check = checkID(travellerID);
    while(check==1) {
        int temp = (int)(Math.random()*90000 + 100000);
        travellerID = temp;
        check = checkID(travellerID);
    }
    
    pw.println(name+","+password+","+travellerID);

    pw.println(name+","+password);
    pw.flush();
    pw.close();

    System.out.println("Congratulations, you have signed up as a passenger!");
    System.out.printf("Your ID is %d \n", travellerID);
    
}
public int checkID(int ID) throws IOException {
    String passengerID = String.valueOf(ID);
    int check = 0;
    BufferedReader br = new BufferedReader(new FileReader("publishedFlights.csv"));
    String line;
    while((line=br.readLine())!=null) {
        String[] values = line.split(",");
        if(values[2].contentEquals(passengerID)) {
            check = 1;
        }
    }
    return check;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source