Difference-list version to read an input line to a list of character
codes. Reading stops at the newline or end-of-file character, but
unlike read_line_to_codes/2, the newline is retained in the output.
This predicate is especially useful for reading a block of lines up
to some delimiter. The following example reads an HTTP header ended
by a blank line:
read_header_data(Stream, Header) :-
read_line_to_codes(Stream, Header, Tail),
read_header_data(Header, Stream, Tail).
read_header_data("\r\n", _, _) :- !.
read_header_data("\n", _, _) :- !.
read_header_data("", _, _) :- !.
read_header_data(_, Stream, Tail) :-
read_line_to_codes(Stream, Tail, NewTail),
read_header_data(Tail, Stream, NewTail).