Fix temp file writing when opening file.