Actually it works, but the fact is that my output file in the form
1 2
2 4
3 9
has to been used as an input for another program and I need it in this form. Actually I could use your method and then write a script to convert in the format I want, but I was hoping to have something more involved, but maybe with PutAppend is not possible.
(* function to write two numbers to a stream followed by newline *)
output[{n_, m_}, stream_] := WriteString[stream, n, " ", m, "\n"]
(* filename *)
file = "temp.txt";
(* open a stream called out, which overwrites it *)
out = OpenWrite["temp.txt"];
(* write several pairs *)
output[{3, 4}, out];
output[{5, 6}, out];
output[{7, 8}, out];
(* close the stream *)
Close[file];
(* print the file *)
FilePrint["temp.txt"]
3 4
5 6
7 8
(* function to write two numbers to a stream followed by newline *)
output[{n_, m_}, stream_] := WriteString[stream, n, " ", m, "\n"]
(* filename *)
file = "temp.txt";
(* open a stream called out, which overwrites it *)
out = OpenWrite["temp.txt"];
(* write several pairs *)
For[i = 1, i <= 3, i++, output[{i, i^2}, out]]
(* close the stream *)
Close[file];
(* print the file *)
FilePrint["temp.txt"]
1 1
2 4
3 9