Added command line parsing.  Name of file to save.  Also cleaned up the code layout a bit.