It's not clear if the only thing you want is the first occurence of TITLE, but assuming it is, the simplest thing to do is to just stop processing your input stream once you are done with first set of title lines. And if you want to avoid "flag" vaiables, you can allways use a nested loop over the input handle.
something like this (psuedo-perl) perhaps...
while (<STDIN>) {
next unless /^TITLE\s+(.*)$/;
my $title = $1;
while (<STDIN>) {
last unless /^TITLE\s+\d+\s+(.*)$/;
$title .= $1
}
print "Here is the title you wanted: $title";
last;
}