Extracting lines which includes a specific word from a document

I have extracted a word from mail using a workflow and passed it into another workflow where i read 1 pdf and 2 word files and write it into a single text file. Then I search the word received from email in the text file using matches and regex pattern and saving the lines which includes that word into a word file.I have added the workflows.

The problem is it is not showing any error but for some words it is writing 2 or 3 lines out of many more in word file and for some words it is not even writing anything.

please help, thanks in advance.

UiPath.zip (23.3 KB)