in reply to Shell Script Woes

Make the assumption that the string won't wrap 3 or more lines (though unlikely)

Why assume that unlikely == impossible? Starting with tye's answer, count the number of newlines in the grep string with the most newlines, buffer that many lines, and use that (+ the current line) to match your pattern.