Post your code for how you're reading in the file. It is possible that your method is dropping all EOL strings as many of Java's default readers use EOL to denote a point to stop reading. It is also possible that the data in your .txt file was stored using a "different" standard than the "\r\n" windows uses. In this case, it is probably just a '\n' character.
There is also the probability that there is no EOL character sequence at the end of the file, in which case your program is trying to access data that simply isn't there resulting in the the StringIndexOutOfBoundsException. To prevent this, check to make sure that your not using charAt() outside of the string's length:
if (index < str.length())
// do your charAt() comparison in here