From: Martin Boese Date: 2008-05-27T21:48:51+09:00 Subject: Re: Problem reading small files - stringio problem? I think your problem is: open('sample.txt', 'w'). You either open a file for append or write, but not both. Remove this line and it might work. Shorter also might be: File.open('sample.txt', 'a') do |out| ('A'..'Z').each do |c| out.puts File.open("#{c}.html", 'r').read end end martin On Tuesday 27 May 2008 12:37:37 Singeo wrote: > Hi, I wonder if someone can take a quick look at this code and tell me > where I'm going wrong. The small files (less than 20k?) that I read in > this array are not appearing in the output file. I understand this is > a problem to do with stringio but have not found a way to fix it. > Thanks. > > letters=("A".."Z").to_a > link_array = [] > > for index in (0...letters.length) > dummy = letters[index] + ".html" > link_array << dummy > end > > open('sample.txt','w') > for index in (0...link_array.length) > guide=File.open(link_array[index], "r+") > html = guide.read > open('sample.txt','a') do |f| > f.puts guide > end > end