It depends on how you are reading and processing the file. Try using trim() expression, it will remove spaces from the beginning and end of the string. Or maybe you need to start your loop from index 1 instead of 0.
If this doesn't help, please post your code and the contents of the text file.