CAPITALIZE WORDS(CodeEval)

CHALLENGE DESCRIPTION:

Write a program which capitalizes the first letter of each word in a sentence.

INPUT SAMPLE:

Your program should accept as its first argument a path to a filename. Input example is the following

Hello world
javaScript language
a letter
1st thing

OUTPUT SAMPLE:

Hello World
JavaScript Language
A Letter
1st Thing

My Code

#!/usr/bin/env ruby -w

def capitalize_word(word)
  word[0].capitalize + word[1..-1]
end

ARGF.each_line do |line|
  puts line.chomp.split.map { |word| capitalize_word(word) }.join(' ')
end