Also checks for EOF at end of input string.