Count Text File Characters
lines = File.readlines("main.rb") line_count = lines.size # from w w w . j a va 2 s. co m text = lines.join total_characters = text.length puts "#{total_characters} characters"