import re

keywords=['<KEY>', '<KEY>', '<KEY>', '<KEY>']


with open("addresses.txt", "r", encoding="utf8") as f:
    searchInLines = f.readlines()

#pattern = re.compile("(" + "|".join(keywords) + ")", flags=re.IGNORECASE)
pattern = re.compile("(" + "|".join(r"\b{}\b".format(i) for i in keywords) + ")", flags=re.IGNORECASE)
for line in searchInLines:
    if pattern.search(line):
        print("word found",line)

import re

keywords=['<KEY>', '<KEY>', '<KEY>', '<KEY>']


with open("addresses.txt", "r", encoding="utf8") as f:
    searchInLines = f.readlines()

#pattern = re.compile("(" + "|".join(keywords) + ")", flags=re.IGNORECASE)
pattern = re.compile("(" + "|".join(r"\b{}\b".format(i) for i in keywords) + ")", flags=re.IGNORECASE)
for line in searchInLines:
    if pattern.search(line):
        print("word found",line)

#pattern = re.compile("(" + "|".join(keywords) + ")", flags=re.IGNORECASE)