added code to read and write results to text file