chmod 0777, $file; # do stuff that writes to file