private void AddAccount(String usernamenew, String passwordnew) {
    final String FileName = "F:/TextFiles/loginaccs.txt";
    File file = new File(FileName);
        try {
            BufferedReader br = new BufferedReader(new FileReader(file));
            BufferedWriter bw = new BufferedWriter(new FileWriter(file));
            bw.write(usernamenew);
            bw.newLine();
            bw.write(passwordnew);
            bw.newLine();
            bw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
}
In this method, I tried to write two extra lines to a text file, which is a new username and a new password.
After deleting some of the lines, the program deletes everything in the text file and write two lines, which is not what I wanted.
Am I doing something wrong? Thanks in Advance.
 
     
    