Move chmod(foo, 0444) into move_temp_to_file()