how to save all the hashes generated into the same csv file and not only the last one Answer Here, you’re overwriting your list_rows variable for every step in the loop. You should append to the list instead, and then write the content of the list to your csv. PS: Try not to override builtin (like hash) that may be