in reply to loop by line on a file

doctext of OP (thanks to Corion's way-back machine) reformatted for easier reading:

Below code loops only once and though i have 5 lines of text in my file it only loops once,
how can i get it to loop 5 times,
i donot want to store the entire file in memory in an array.

open my $fh,"+<four_comma.txt" or die "Cannot open text $!"; my $i=0; while(<$fh>){ say $_; say ++$i; }