Ruby:Read a Text File
You can open a text file and read each line.
This code iterates over each line of the file.
The text file http://progzoo.net/haggis.txt includes some lines of text.
You can open a text file and use the gets method.
You can open a text file and use the readlines method.
In this example all lines are read into array a. We print out line number 2 (the third line).