Applescript File not open with write permission error

I have an applescript that works perfectly on my local machine. It opens the file and writes to it and then closes. My Applescript is being tested and saved as a .app so it is an application. When I put the application on my server to test out the user experience it never propely opens the file and gives me this error:

“File not open with write permission.
Finder got an error: File not open with write permission. (-61)”

Why would this work on my local machine and not work after being downloaded from my server? I have tested that my path’s are correct and like I mentioned everything works perfectly on my local MAC machine. I have tried everything…making it a POSIX file, alias, text, string and nothing ever works. Here is the section of my Applescript code that seems to be throwing the error:

set motionFullPath to ("" & pathGenerators & "" & generatorPlugin & ":" & theFolders & ":" & lastLayer & ":" & motionFiles & "") as string
						set myFile to open for access file motionFullPath with write permission
						set endOfFile to (get eof myFile) as number
						if result > 0 then
							set theText to read myFile
							set eof myFile to endOfFile
							write "<!--uuid:" & theURL & "-->" & return & theText to myFile
						end if
						close access myFile

The error suggests there’s a problem with the path. Show us how the script gets that path.

I can’t see anything in the posted code which would cause the problem. The lines between the opening and closing of the access aren’t protected by a try statement, but if the script’s an applet, anything it opens should be closed anyway when it crashes or quits. I’m not clear if the script’s being run remotely (in which case there may be security issues) or downloaded and run on the users’ machines.

Just to point out that, as posted, the code appends the modified text to the end of the current text. If it’s meant to replace it, set eof myFile to 0 instead.

Well I came across the issue which is that my .app is quarantined. But I am super confused how can my .app be properly codesigned and yet still be quarantined by Apple? I have an app called that I downloaded from my server and made sure that it was codesigned correctly but yet it is still quarantined? I thought that having a valid code signature was the whole point of getting past Gatekeeper?

MyMac-7:Downloads user$ ls -l@
total 0
drwxr-xr-x@ 7 user staff 238 Apr 21 08:05 Contents 67

MyiMac-7:Downloads user$ codesign --verify --deep --strict -vvvvvvv valid on disk satisfies its Designated Requirement

MyiMac-7:Downloads user$ spctl -a -t exec -vvvvvvv accepted
source=Developer ID
origin=Developer ID Application: myID

Everything downloaded is quarantined, regardless of code-signing. It means you get the confirmation dialog the first time you run it, after which the quarantine bit is removed.