write to temp file