For Each loop causing infinite loop?

Hi all,

I am having a relatively straightforward problem. I am running a while loop with nested for each loops. The while loop is dependent on the number of iterations of these for each loops. Appending to these for each loops within the while loops is causing an infinite loop crash. See below:

This is the only place I edit the array for the for each loops. it is outside and of the for each loops themselves. I know this is the error because if I remove the append the code compiles and runs.

Thanks in advance!

Where do you decrease the RoomCount?