C# Extension method: Searching lines containing specific string

Searching for lines in text file containing a specific string can be very handy with below code snippet. This method is very optimal specially if we are accessing log/error/access files. public static IEnumerable<string> ReadAndFilter(this FileInfo info, Predicate<string> condition) { string line; using (var reader = new StreamReader(info.FullName)) { while ((line = reader.ReadLine()) != null) { …