I have sorted the problem.
I gave each of the fastboot commands in the script manually one after another, and it worked.
My guess is that the automated script ./flash-all.sh waited for 5 seconds after asking the bootloader to reboot. 5 seconds may not be enough to do that.
Kindly look at this bug.