Write to temporary file