Fix writing to file.