Parsing a ruby code

Hello,
I am using the below given code to parse ruby code line by line and
generate its s-expression (AST). The help i need from you is that i want
to parse the whole ruby file at a time instead of parsing line by line.

   require "ruby_parser"
  # puts RubyParser.new.parse("My name is defecto")
   counter = 1
   file = File.new("readfile.rb", "r")

   while (line = file.gets)
      puts "#{counter}: #{RubyParser.new.parse(line)}"
      counter = counter + 1
   end

···

--
Posted via http://www.ruby-forum.com/.