Fixed writing out files.