Thank you for your post.
First, an error 4 is "Command Unknown". In Manage Scripts, select your script, and at the bottom, change the pop-up below Show Compatibility to "iOS". This will then show you what commands are allowed in FileMaker Go.
What is the contents of the $file variable?
When using "Open URL", you need to use "fmp://" for FileMaker Go 12, and "fp7://" for FileMaker Go 11.
For testing purposes, insert after each script step "Show Custom Dialog" step using "Get (LastError)" function to return the last error from each step. This will allow you to step through the script steps and narrow down the issues.