We can get into infinite loop if we have a closing tag at the very beginning of the html page. Then we start out with i == -1 and get into infinite loop.