Change an existing text-file

I read in a script of Ron Fleckner (@ Ron: thank you…) how I can teach Apple Script to write a text in a new text-file!

set f to open for access (path to desktop as text) & "Name of File" & ".txt" with write permission
write "anything" to f
close access f

Apple Script makes now a new text file with the Name “Name of File.txt” and the text “anything”.

I changed Rons script a little bit, so that I can write with Apple Script in existing text-files…

set f to open for access (path to desktop as text) & "open this file.txt" with write permission
write "anything" to f
close access f

But when i write now in an existing file with my script, it overwrites the old text of the file.

For example:
The old text in the file was:
My name is Nicki!

When I write now with my script “anything” to the text, the text is changed to:
anythingis Nicki!

How can I teach Apple Script not to overwrite the old text beacause I want the text like this:
anything My name is Nicki!

I hope you can help me

Change the line to:

write “anything” to f startting at eof

You may decide that you need “return” characters at the end of each line to separate each entry as follows"

write “anything” & return to f startting at eof

Andy

thank you andy! it works!

greetings, nicki