Hey i writing a program that´s supposed to searches through .log files and find a keyword "Complete Respons". All found keywords should later be writen and saved in a new .txt file. I have now managed the program to search through one document at the time, but i have +50 documents of the same typ in one directory that i want to search through all at the same time and put all found keyword in the same .txt document. I could really use some help...! Thanks
def read_log_file(filename, keyword):   #file
    saved_word = []  # Array
# read file
    with open(filename) as file_search:   #open search file
        file_search = file_search.readlines()   #read file
    for lines in file_search:    # every word is scaned
           if keyword in lines:   # extract the keyword
                saved_word.append(lines)    #store all found keywords in array
        # write in new file
    with open('CompleteResponse.txt', 'w') as file_handler:
        file_handler.write(f"{filename}\n")
        for i in range(len(saved_word)):
            file_handler.write(f"{saved_word[i]}")
    print('done') # completed
    print(len(saved_word)) # count found words
read_log_file(r'C:\Users\\Documents\read_log_files\test.log', 'Complete Response:')
 
    