ok, I have the following, very simple code:
f = \"String1\\n\\n\\nString2\\n\\n\\n\" f.each_line do |t| t.delete! \"\\n\" puts t.inspect end
f = "String1\n\n\nString2\n\n\n" f.each_line.collect(&:chomp).reject(&:empty?) #=> ["String1", "String2"]
The collect(&:chomp) removes line endings. reject(&:empty?) throws away all of the empty lines.
collect(&:chomp)
reject(&:empty?)