added ability to output to file