I would like to read a file, modify lines and write the results to another file.
readtofile :- open(\'inputfile.txt\', read, Str), read_file(Str,Lines),
I would write something like
tranform_file :-
open('inputfile.txt', read, I),
open('outputfile.txt', write, O),
transform_lines(I, O),
close(O),
close(I).
transform_lines(I, O) :-
read_line_to_codes(I, L),
( L == end_of_file
-> true
; transform_line(L, T),
format(O, '~s~n', [T]),
transform_lines(I, O)
).
(note: untested)