Fix broken loop causing OutOfMemory exception

*blames @NuckChorris*