for (my $i = 1; $i < 5; $i++) { open (INPUTFILE, "<:encoding(UTF-8)", "in.txt") or die "Can't open file: $!"; print "\n-----------------------LOOP $i-----------------------\n"; while ($line = ) { print "line $.: $line\n"; } close INPUTFILE; }