Added check for unterminated loop.