I'm writing a program to help me search for a keyword inside thousands of files. Each of these files has unnecessary lines that i need to ignore because they mess with the results. Luckily they're all located after a specific line inside those files.
What i've already got is a search, without ignoring the lines after that specific line, returning an Enumerable of the file names containing the keyword.
var searchResults = files.Where(file => File.ReadLines(file.FullName)
.Any(line => line.Contains(keyWord)))
.Select(file => file.FullName);
Is there a simple and fast way to implement this functionality? It doesn't necessarily have to be in Linq as i'm not even sure if this would be possible.
Edit:
An example to make it clearer.
This is how the text files are structured:
xxx
xxx
string
yyy
yyy
I want to search the xxx lines until either the keyword is found or the string and then skip to the next file. The yyy lines i want to ignore in my search.