Added parameter to allow for user-defined output file, and decomposed main parsing routines into data extraction and data analysis routines