Use a 'while' loop when iterating over modules to allow modules to extend the module list.