public static string Find(this ILineReader reader, [Implicit] ICallContext context, Func <string, string> comparer, bool flushIfNotFound = false) { var peaker = reader.Peak(); ILineReaderEntry last = null; foreach (var entry in peaker) { var result = comparer(entry.Text); if (result != null) { reader.Flush(entry); return(result); } last = entry; } if (flushIfNotFound) { reader.Flush(last); // First flush until the last seen entry reader.Next(); // ... then also flush the last seen. } return(null); }