Reworked to remove socket problems

reworked to fix socket problems and have parsing write to a file
specified by the third command line argument