How can I Save a log in TextEdit or word or whatever?

I’m trying to write a script that connects to the internet and saves a log that keeps track of the time I stay conected to the internet (via telephone) but I keep getting an error I don’t now how to fix. The most amusing part is that the file is saved with the correct data I asked for, but returns an error anyway.
Here are some of the things I tried with no success:

archivo would be the name of the file (defined somewhere else)
carpeta would be the folder

Tell app “TextEdit”
make new document at the beginning of documents with properties {name:“” & archivo}
set the name of window 1 to archivo
set zoomed of the front window to false
set visible of the front window to true – false false when it all works
set the text of the front document to Datos as string
save the front document in (archivo) – this one actually saves it, but returns error
– set the carpeta to path to desktop folder as alias
– close front document saving in file {archivo} as alias saving ask
– in the folder “Desktop” of the folder “nico” of the folder “Users” of the disk “Mac HD”
– in file (“Mac HD:Users:nico:Desktop:” & archivo)
– the error is here, but I don’t understand what happens

		--«event ascrgdut» 	This is the returned error!!

end tell

It would be nice if I could save the log always in the same file (and just add text to it)

Hi, Nikel!
To save a simple plain text file, you may consider standard additions’ read/write commands. Eg:

appendText("this is a test", alias "path:to:logfile.txt")

to appendText(thisText, thisFile)
     set fileRef to (open for access thisFile with write permission)
     write thisText to fileRef starting at ((get eof of fileRef) +1)
     close access fileRef
end appendText

ascrgdut is a magic event which makes wake-up scripting terminology of apps and osaxen, but I don’t know wheter is related to your problem. I can’t see the connection :shock:
Could you test this code and see what happens? Simpy open or create a document in TextEdit and see what’s going on:

tell app "TextEdit" to set bounds of window 1 to {100,150,300,400}