while (my $line = ) { chomp $line; die "Request Id $id already present in file\n" if $line =~ /$id/; }