Thanks Harry, your solution is good for me. Your strategy is actually 
convert the text into an array line by line, and then pick up what you 
want to format. I learned much from your example.

Something that I don't understand is why you need add:
<quote> f.puts if y.size==0 </quote>
Are you going to print a new line?

Hello Robert, I like your recommended style; it will make the script 
more reusable. As to output, I am OKAY to STDOUT or file_io, but this 
might be my mistake which I showed in Perl with STDOUT but actually I 
required file_io. :)

-- 
Posted via http://www.ruby-forum.com/.