Creating Plugin from Rhino Python - file output problem

I created a plugin from a debugged and working Python script. Initially the plugin did not execute as the original script and terminated before running to completion. The original script opened an output file and wrote text to the file and it seems that this was the problem. After the file open, write and close statements were commented out the plugin ran to completion and produced the correct drawing in Rhino. Is there a problem with file I/O when compiling Python and creating a plugin?