Try to use .rtf instead of .txt

I also had problems with it. Otherwise this is some code i have used to write into .rtf files.

Code:
STRING* url_text = "";
str_cpy(url_text, "http://www.3dgamestudio.de/\n";

var filehandle = file_open_append ("url.txt"); // better use "url.rtf"
file_str_write(filehandle,url_text);
file_close (filehandle)