Cutting power repeatedly a large number of times is a great way of eventually bricking the box.
This modem has an admin web interface. The author could have used it to trigger a restart.
The whole thing could have been automated with just a pi at 100 times less cost, effort and risks.