Convert contents to string before writing to temp file