4.6.5.5 Finding the End of Line and End of File

To test whether the end of a line on the end of the file has been
reached on the current or given input stream, use
at_end_of_line/[0,1] or at_end_of_stream/[0,1].

Note that these predicates never block waiting for input. This means
that they may fail even if the stream or line is in fact at its end. An
alternative that will never guess wrong is to use peek_code/[1,2]
or peek_byte/[1,2].