added .close to for loop