I'm trying to input a html file and copy everything from that file to a new html file with some changes. I need to read the html file word by word and compare them to a file with some keywords. If a keyword matches a word in the html file then it will add italic tags around that word in the output html file. As it is now it doesn't output anything.
Logically I want to read a word from the html file and then compare it to every keyword and output the result.
fileIn = original html file
keyword = keywords file
outFile = html file writing to
You try to read the keywords from file every time you read a word from the fileIn. This might work the first word but for the rest keywords.good() will always return false. What you need to do is to read the keywords before the main loop and save them in some data structure. I would recommend a set in this situation. The could would look something like this:
Thank you that worked for the most part. The only thing that doesn't work is if the word is directly followed by a punctuation mark. Is there an easy way to fix this for all punctuation or will I need to write several if statements for each type of punctuation?