It's a bit much to change here, but this is going to rewrite the same file a bunch of times. Maybe the loop is at the wrong level of abstraction, and should be inside the DHCP Manager?