This is probably a very simple question, but it is driving me nuts. I have a script that includes the following code:
try set theFileID to open for access theFile with write permission write theFileBody to theFileID close theFileID on error display dialog "Can't write file" end try
Works fine; the text file is written with no problem. However, I cannot thereafter delete the file. I can send it to the trash, but when I try to empty the trash I get an error that says “The operation cannot be completed because the item ‘FDL20071112-30460.txt’ is in use.”
Why would I get this? Am I missing some sort of “flush” or “finish” statement that is necessary in order to make the item no longer in use?