From: Patrick Doyle Date: 2008-09-12T21:26:40+09:00 Subject: Re: strange behaviors in writing/saving file On Fri, Sep 12, 2008 at 8:16 AM, Li Chen wrote: > > ##here is the code line to print the results to the screen and save to > the file > File.open('test.txt','w'){|f| puts e.inner_text; f.puts e.inner_text} > > ##screen results: > abacus > (n.) > A manual computing device consisting of a frame holding parallel rods > strung with movable counters. > abacus > (n.) > A slab on the top of the capital of a column. > > ## written/saved file > A slab on the top of the capital of a column. I am guessing from the context that the code you posted is in some sort of loop that fetches a line of text from the website. Perhaps something like while (e.inner_text = gets) File.open('test.txt','w'){|f| puts e.inner_text; f.puts e.inner_text} end In this case, each time through your loop, you open "test.txt", destroying whatever it contained before, write one line, and then close the file. If you want to append to the end of the file each time you open it, you will need to change 'w' to 'a', in your call to File#open. --wpd