fixed up output file stuff