Fixed bugs in check_outfile