I think the error is in the read function. It cannot read beyond the special character in the image See repr output
I have using string.find() in python as follows:
indexOfClosedDoc = temp.find("</DOC>",indexOfOpenDoc)
However, when the string has text as below:
SUB
</DOC>
where SUB is a special character, temp.find cannot find the tag. Any suggestions on how to fix this
Example:

Code that causes it to fail:
handle = open("error.txt",'r');
temp = handle.read();
index = temp.find("</DOC>",0)
if(index == -1):
print "Error"
exit(1)
Put the image text in a text file and run the code
Here is repr of the temp variable for the text in the example. The text in eror.txt is everything from line 29722 in the image
' </P>\n\n'
NOTE: The read() function never read beyond SUB so finding is out of the question
The answer is to open the file using ‘rb’ mode. On Windows, opening the file with just ‘r’ will cause it to use the old DOS behaviour of stopping at 0x1A (a DOS EOF character). See also Line reading chokes on 0x1A