This version of the program works fine, and prints out results into a .txt file