I think he meant `one line', not `one newline', but that's a minor issue.
you could also do something along the lines of (pseudo-code):
Code:
stringbuffer b;
b.append("myline\n")
for char in filestream('file.txt'): b.append(char);
f = filestream('file.txt', 'w');
for char in b: f.write(char);
f.close();