fix function to read arguments instead of global variable args.infile and args.outfile