3.3. Process a file line by line

Example 3-4. examples/files/read_file.p6

#!/usr/bin/perl6

my $filename = "examples/files/read_file.p6";

if (my $fh = open $filename, :r) {
    for $fh.readline -> $line {
        say $line;
    }
} else {
    say "Could not open '$filename'";
}

The for loop in our example repeatedly calls =$fh and
on ech iteration it places the retreived string in the $line variable.

This script is very similar to what the unix cat command does.