Problem with error message

Hi, it worked, thanks, but why did you make an extra delay, and why did it work???

That is your homework:)
Follow the code by hand, read it carefully line by line.
Be the Arduino !
and do what the code says and you will understand.