display(S, Term) is equivalent to write_term(S, Term, [operators(false), dotlists(true)]).
Note that as usual, the output is buffered, so it may need to be flushed either by closing the stream, by writing again or by using flush/1.
Success:
display(output, 3.0). % displays 3.0
set_stream(a,output), display(a,hi). % displays hi
?- open(file1,update,S), display(S, X+2), close(S).
X = _72
S = 6
yes.
?- sh('cat file1').
+(_98, 2)
yes.
Error:
display(S, a(b,c)). (Error 4).
display("string", a(b,c)). (Error 5).
display(9, X=2). (Error 192). % stream not open
display(atom, X=2). (Error 193).