Shouldn't the umask be reset after creating the file, regardless if it succeeded or failed?