Ruby One-Liner

I know it’s not good engineering practice, but I do love code golfing and writing one-liners in Ruby. This turns a tab-delimited flat file into an imperfectly compliant CSV file:

File.open($*[0]) { |f| puts f.readline.strip.split("\t").inject([]) { |newfields, field| newfields << "\"#{field}\"" }.join(',') until f.eof? }

It works well as long as there are no commas in your fields.