On Oct 15, 2007, at 12:41 PM, Simon Schuster wrote:

> it seems that I have to run it a couple different times for it to
> work.. array.length = 16576, if that could be a potential problem. if
> it is, how do I work around it?
>
> 077:0> array = File.read("/text.txt").to_a.each { |x| x.chomp! }

That's better written as:

lines = File.readlines("/text.txt")
lines.each { |l| l.chomp! }

> 080:0> array.each_with_index { |x,y|
>     array.delete_at(y) if x.empty? == true
> }

And this can be as simple as:

lines.delete_if { |l| l.empty? }

However, I would switch strategies and only add the lines you are  
interested in to begin with:

lines = Array.new
File.foreach("/text.txt") do |line|
   line.chomp!
   lines << line unless line.empty?
end

I hope that helps.

James Edward Gray II