I'm trying to write some code to parse out comments from an html file, as it is now, it parses out the first comment fine, but any subsequent comment isn't removed.. it finds the start tag odf the comment but string.IndexOf(ENDTAG,currentposition) always returns -1 even tho i can see it inthe stream, past the currentposition integer..

Code:
iTotalCnt = strData.Length;
            char [] pData = new Char[iTotalCnt];
            pData = strData.ToCharArray();
            while (iCurrentCnt < iTotalCnt)
            {
                /*
                 * * skip comments
                 */
                if ((pData[iCurrentCnt] == '<') && (pData[iCurrentCnt+1] == '!'))
                {
                    /*
                     * iCurrentCnt should be first character to replace.
                     * Find the end of the comment and delete it all.
                     */
                    MessageBox.Show(String.Format("iCurrentCnt = {0} / iEndOfComment = {1}",iCurrentCnt,iEndOfComment));
                    iEndOfComment = strData.IndexOf("-->", iCurrentCnt);
                    MessageBox.Show("iEndOfComment = " + iEndOfComment.ToString());

                    if (iEndOfComment == -1)
                    {
                        MessageBox.Show("Couldn't find end of script");
                        iCurrentCnt += 1;
                    }
                    else
                    {
                        strData = strData.Remove(iCurrentCnt, (iEndOfComment - iCurrentCnt) + 3);
                        iCurrentCnt += (iEndOfComment - iCurrentCnt) + 3;
                    }
                        MessageBox.Show(strData);
                }
                else
                    iCurrentCnt++;
            }
It always parses out the first comment, finds the start tag of the second comment, and then IndexOf returns -1 when looking for the end tag, even tho I can see it clear as day in the string past the iCurrentCnt position.

Any help is much appreciated,

thanks