From: Tobias Reif Date: 2002-05-06T20:33:24+09:00 Subject: Re: newbie Q: how to strip blank lines from file? David Alan Black wrote: > The regex doesn't match a blank line -- you need a * instead of a +. ... or use \A\s+\z (?) open("out.txt", "w") do |out| open("lines.txt").each do |line| out.print line unless /\A\s+\z/.match(line) # both seem to work, but Dave's is the prettiest anyways :) # out.print line unless line.strip.empty? end end Tobi -- http://www.pinkjuice.com/