Fixed list iteration over removing invalid files