Help with Open for Access Write to file

Hello All, I have a problem writing data to a file using the open for access method. I have included the errors in the comments of my code. Any help would be appreciated.

Also, theData is a string

tell current application
	set JDFPath to ((iCutHotFolder & finalOutputName) & ".jdf" as string) --Result-- Macintosh HD:Users:pkincaid:Desktop:Test XML:Item:AmericanCars_4.jdf
	set JDFfile to (open for access file JDFPath with write permission)
	set eof of JDFfile to 0
	write thedata to JDFfile starting at eof -- Errors with «class ocid» id «data kptr00000000E092AB0304000000» doesn't understand the «event rdwrwrit» message. (error -1708)
	close access JDFfile
end tell

try

log class of theData

This is the result I get

<NSAppleEventDescriptor: ‘ctxt’>

So now that we know my class of the variable is text, do I have to coerce it to something else? If so can you explain to me how?

Thank You

NSAppleEventDescriptor is a Cocoa object, so coerce it to text


.
 write (thedata as text) to JDFfile starting at eof
.


    write (theData as string) to JDFfile as text starting at eof