rough syntax error line detection and infinite loop prevention