Windows uses CRLF as line breaks. And you crack on LF. This will not work.
Safe way:
System.getProperty("line.separator");
to get the appropriate delimiter on your OS.
String newLine = System.getProperty("line.separator"); myText.split("(?:" + newLine + ")+");
Perhaps you are reading a file created on another OS. Then the above method will not work. The best way is to use a character class with CR and LF , as pointed out by @Marko's comments:
myText.split("[\r\n]+");
source share