while (<>) { # your code here } continue { close ARGV if eof; # Not eof()! }