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), close(Str). read_file(Stream) :- at_end_of_stream(Stream). read_file(Stream) :- \+ at_end_of_stream(Stream), read(Stream), modify(Stream,Stream2), write_file(Stream2), read_file(Stream). write_file('outputfile.txt', Phrase) :- open('outputfile.txt', write, Stream), writeln(Stream, Phrase), close(Stream).
I would write something like
(note: untested)