Added write flag, outfile name string and file pointer; added getopt check for write flag; stdout suppressed if writing to file