Time delay within a loop?

You might want to use setInterval() instead.