Joseph Paish wrote:

> assuming that each line of the output is called single_record, when i type 
> single_record.class, i find out that it is an Array.  so far, so good.
> 
> when i include the line 
> 
> puts single_record.join(" ") 
> 
> in the script in order to print single_record out as a space-separated string, 
> i get the following message : 
> 
> my_command_prompt$ ruby ~/ruby_dir/program_name.rb
> nil
> /my_command_prompt/ruby_dir/program_name.rb:377: undefined method `join' for 
> nil:NilClass (NoMethodError)
>         from /my_command_prompt/ruby_dir/program_name.rb:239:in `each'
>         from /my_command_prompt/ruby_dir/program_name.rb:239

I'd suggest using the ruby-breakpoint library to place  assert { 
single_record != nil }  statements after every statement that alters the 
variable in the code. It will automatically open an interactive IRB 
shell at that place if the assertion fails. You can leave the assert() 
statements in the code -- they can be setup so that the overhead in 
non-debug mode is exactly the same as that of calling a method that does 
nothing.

It's available at http://ruby-breakpoint.rubyforge.org/ or via "gem 
install ruby-breakpoint".