If you have the file contents already in memory as a string, you don't need to write it to a file again to determine if the last line is empty. Just split the contents by an end-of-line character and then trim whitespace off the last line and see if anything is left:
String fileContent = "line1\nline2\nline3\nline4\n";
// -1 limit tells split to keep empty fields
String[] fileLines = fileContent.split("\n", -1);
String lastLine = fileLines[fileLines.length - 1];
boolean lastLineIsEmpty = false;
if(lastLine.trim().isEmpty())
{
lastLineIsEmpty = true;
}
//prints true, line4 followed by carriage return but
//no line 5
System.out.println("lastLineEmpty: " + lastLineIsEmpty);