Add output file as an argument; made seperate static method for printing to output.