changed the script to write down to a single file