Question - How to read a file in Ruby? 
          
        
        Answer - 
        
There are three different methods to read a file.
To return a single line, following syntax is used.
Syntax:
f.gets  
code...  
To return the whole file after the current position, following syntax is used.
Syntax:
f.rea  
code...  
To return file as an array of lines, following syntax is used.
Syntax:
f.readlines  
[code...]