Move the preference.write() call inside the for loop
Scripts in this folder are meant to have an "owner" who maintains them.