When using SWI-Prolog on Windows and reading text files for conversion into characters codes and needing to preserve the CR with LF some special attention is needed.
Normally a file would be opened as a text file and read but that results in the CR with LF being converted to just a LF.
To preserve the CR with LF use set_stream/2 with
to_codes(File_path) :- setup_call_cleanup( open(File_path,read,Stream), ( set_stream(Stream, newline(posix)), read_stream_to_codes(Stream,Codes), format('Codes: ~w~n',[Codes]) ), close(Stream) ).
; test followed by
?- to_codes('C:/Users/Eric/Documents/.../test.abnf'). Codes: [59,32,116,101,115,116,13,10] true.
A case in point where preserving CR with LF is needed is when working with ABNF files.
There are several good but dated references regarding SWI-Prolog and ABNF (search)