Fixed bug in tag remove function.

The for loop in getTagElement had two statements in the condition, causing an infinite loop if the element did not exist.