readline() on closed filehandle $LISTDEL at ./delete_list_ver3.pl line 12 (#1) (W closed) The filehandle you're reading from got itself closed sometime before now. Check your control flow. #### #!/usr/bin/perl use strict; use warnings; use diagnostics; if (@ARGV = 2){ my %delList; open my $BEEPON, '>>', "./beepon.file"; open my $BEEPOFF, '>>', "./beepoff.file"; open my $LISTDEL, '<', $ARGV[0]; foreach (<$LISTDEL>){ chomp($_); $delList{$_} = 1; } open (my $ORGLIST, '<', $ARGV[1]); foreach my $entry (<$ORGLIST>){ chomp($entry); print { exists $delList{$entry} ? $BEEPON : $BEEPOFF } $entry . "\n"; } close $LISTDEL; close $BEEPON; close $BEEPOFF; }