With this line we checking if node still rebooting and available via ssh while rebooting, or already rebooted once and have some message in lastlog like "reboot" or "login". If node is rebooting the last message in lastlog will be "down" and no login attempt will be logged - we checked that.
The idea about sleep is okay - there is cases when we can inter loop here without delay.