Here is my code. Everything works except the last two lines. I am trying to remove a line from a .txt and rewrite the file into a tempfile and then rename the tempfile to original. The last two lines are being ignored though. Here is what the error is:
https://i.gyazo.com/66a320aeaf487837ce64fe3424074de6.png
These two lines are being ignored:
inputFile.delete();
tempFile.renameTo(inputFile);
File inputFile = new File(a.getDirectoryData() + "UserTwo.txt");
File tempFile = new File(a.getDirectoryData() + "TempUserTwo.txt");
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
String currentLine;
while((currentLine = reader.readLine()) != null) {
String trimmedLine = currentLine.trim();
if(trimmedLine.equals(a.username + ":" + a.password)) continue;
writer.write(currentLine + "\r\n");
}
reader.close();
writer.close();
inputFile.delete();
tempFile.renameTo(inputFile);