My dhcp file is stock, however you raise a good point @sammo. A revised version of the code using your in-place edit has been attached to my previous post as portal-v2.zip.
Thanks to everyone who has contributed to this effort.