From: brabuhr@... Date: 2010-07-10T04:19:45+09:00 Subject: Re: FIRST PROGRAMMING PROBLEM Array On Fri, Jul 9, 2010 at 1:44 PM, Francisco Martinez wrote: > f=File.open(txtFile) > f.each do |line| >  if(line=~/\t(.+)/) >   puts("token= #{$1}") > end > f.close Instead of opening and closing a file, you can pass a block to open and the file will automatically be closed: File.open(file) do |f| #... end http://blog.rubybestpractices.com/posts/rklemme/001-Using_blocks_for_Robustness.html You might also want to look into methods like 'foreach' and 'readlines'.