added a longer test document. highlight function is broken because str.replace() doesn't seem to like brackets, it changes data type to list.  Consider using regular expressions
called file.readlines() instead of file.read() which was causing the fail, not the brackets in the string as originally thought
test

test
Using String.replace() to replace query terms with the highlighted term had a side effect of also replacing substrings.  Is the document is now instead split into stringm tokens and the tokens are highlighted.  Adjacent tokens are highlighted together.