ファイルを読み取り、行を変更して、結果を別のファイルに書き込みたいと思います。
readtofile :- open('inputfile.txt', read, Str), read_file(Str,Lines), 閉じる(Str)。 read_file(ストリーム) :- at_end_of_stream(ストリーム)。 read_file(ストリーム) :- \+ at_end_of_stream(ストリーム), 読み取り (ストリーム), 変更 (ストリーム、ストリーム 2)、 write_file(ストリーム2)、 read_file(ストリーム)。 write_file('outputfile.txt', フレーズ) :- open('outputfile.txt', 書き込み, ストリーム), writeln(ストリーム、フレーズ)、 閉じる(ストリーム)。