writing html - OS 10.4 vs. 10.5

I have written a little script that generates an html file and writes it to the desktop. The portion of the script that writes the file was literally copied from a post here:

on write_to_file(the_file, the_data, with_appending)
set the_file to the_file as string
set f to open for access file the_file with write permission
if with_appending = false then set eof of f to 0
write the_data to f starting at eof as (class of the_data)
close access f
return true
on error the_error
close access file the_file
end try
return the_error
end try
end write_to_file

This script works brilliantly on my MacBookPro. I then put the script on another machine (the actual production machine where i would ultimately be using the script), and it didn’t work right. The html file is generated, but when I open it in a browser, it physically displays the html (as if it were written in as text). I can copy and paste it into a new file and save it, and it again displays normally. After testing on about 4 other machines, I have realized that the only difference between machines is the OS. It consistently works on OS10.5 machines, and it consistently fails on OS10.4 machines. Problem is the 10.4 machines HAVE to stay on 10.4 due to other software limitations…

Anyone have any ideas as to why 10.4 writes the file differently? Is there a simple way to make this work in 10.4? Running the script on my MBP is becomming a pain!

try doing your write statement with this

as «class utf8»

Genius! It now works in both 10.4 and 10.5.

Many thanks!!

no problem, I got stuck with that problem a while back.