Fix weird issue with clang on OS X 10.9.

When building with the default CFLAGS used by python the code will
go into an infinite loop here, putting the same two files in the list
infinitely. Switch this to use a while loop and increment the iterator.