my $wordlist = 'wordlist.txt'; if(! -s $wordlist) { print "File is empty\n"; exit 0; } else { # your code goes here }