open (my $FH, "<", $file) or die ... # reads the whole file, assigns first line to $headline my ($headline) = <$FH>; # since the whole file is already read, there's nothing # more to be read, so the while block will never be executed while( my $line = <$FH> ) {