An even simpler way here would be
print OUTFILE grep /$phrase/, <INFILE>;
Unfortunately replacing while with a map or grep results in slurping the file to search it, which is most likely undesired with logfiles. It can be whittled down though:
/$phrase/ && print OUTFILE $_ while <INFILE>;