On UNIX systems, check that your account has permission to create files in the directory where filename would be created. Look for other, more explicit, error messages from the operating system. Possibly the disk is full, or you have reached a limit on the number of open files.