This code is wrong:
String result = ""; while (scanner.hasNextLine()) { result += scanner.nextLine() + System.lineSeparator();