fixed program not outputting to a file