When I had that problem it was because the webserver runs as some special user, perhaps 'web', and 'web' does not have the rights to write a file in the directory where it is attempting to write one.
Look in your webserver's error logs to see if you are getting any kind of insufficient rights error messages.
Comment on Re: Open to and save from same file in CGI