Getting ready

In this recipe, you'll see a file enumerable function as it exists in other, mostly dynamic, languages. The goal is to enumerate all the rows in a text file without explicitly opening, reading, or closing the file (this is done automatically in the background), as shown in the following code:

var 
  row: String; 
begin 
  for row in EachRows('....myfile.txt') do 
    WriteLn(row); 
end; 

Nice, isn't it? Let's start.