Thanks everyone - Robert's method works for me with minor alteration.
The errors in the example were not in the actual file.

BTW:
Christer's answer gives me:
"undefined method `lstrip' for nil:NilClass (NoMethodError)"

Robin's method gives me:
private method `gsub' called for nil:NilClass (NoMethodError)

Thanks to all !