Fix writing the files to disk