It's working right for me. Are you sure you are not receiving errors on command prompt ?
Note: to output stderr you should use 2>
filename
Example (test.pl):
:- initialization(main).
main:-
repeat,
read(Term),
writeln(term(Term)),
Term=end_of_file -> halt, fail.
swipl.exe -f test.pl < test.pl > test.txt 2> stderr.txt
writes on test.txt:
term((:-initialization main))
term((main:-repeat,read(_G747),writeln(term(_G747)),_G747=end_of_file->halt,fail))
term(end_of_file)
and on stderr.txt:
% c:/swi/workspace/test.pl compiled 0.00 sec, 4 clauses