Note that as usual, the output is buffered, so it may need to be flushed (e.g. explicitly using flush/1).
Note The output of write/1 is not necessarily in a form acceptable to read/1,2.
Success: [eclipse]: open(file1,update,s), write(s, X + 2), close(s). X = _g72 yes. [eclipse]: sh('cat file1'). _g72 + 2 yes. Error: write(S, a(b,c)). (Error 4). write("string", a(b,c)). (Error 5). write(9, X + 2). (Error 192). % stream not open write(atom, X + 2). (Error 193).