implement port,file,output_mode for command-line args, still some problems though
edited cli args, fixed warnings and loop error