in reply to Re^2: perl one liner to print a line
in thread perl one liner to print a line

I prefer:

perl -ne'print and close ARGV if $. == 4' file.txt

It works better with multiple files on the command line.      ;-)