Use the developed functionality to write the results into a CSV file instead of displaying it on the terminal.