That suggests that 10 (0x0a, or Line Feed) is sitting in your input buffer, probably from a previous operation - you've probably stopped at 13 (0x0d, or Carriage Return) previously, when you should have stopped at line feed. The best solution would be to clear it out of the input buffer at the correct time, on the previous operation. Alternatively you could flush the input buffer before executing the above code.