From: Dave Thomas Date: 2002-05-06T11:54:44+09:00 Subject: Re: newbie Q: how to strip blank lines from file? Stewart Midwinter writes: > Well, I've spent a few days reading about Ruby, and want to try my first > project: a little utility that will read a file that has too many blank > lines in it, and strip out all of those blank line (could contain spaces or > tabs). A simple solution might be something like IO.foreach("snip.txt") do |line| puts line unless line.strip.empty? end Or, using the regular expression approach you used: IO.foreach("snip.txt") do |line| puts line unless line =~ /^\s$/ end Cheers Dave