Add feature of writing the results to a text file