Shouldn't that be cEndIndex >= cStartIndex? If you call this method with param _tag_ = "<script" would still insert into the comment.