in reply to timelocal error wired behaviour

After this, it ubruptly ends

That's not really surprising because there's no loop in your code. Perhaps an SSCCE would be useful to aid in the diagnosis?