Change some while loops to for loops in config.c