You can record the ascii value of the terminating character, as a global state variable possibly, and test for zero to exit the line-reading loop.
I use global state variables in the compiler to hold parsing data like word-position word-ascii, next- word-position, word-length.