From: "Eric I." Date: 2008-06-05T02:24:12+09:00 Subject: Re: Beginner: Read file On Jun 4, 1:08 pm, Justin To wrote: > report = File.open('ReportTxt.txt', 'r') do |L| >    while line = L.gets > >   report.getc.chr > >     end > end > > I'm quite lost...what I'm trying to do is read a file character by > character > until I've read every character. Hi Justin, A couple of things. You've combined two distinct ways of using the call to open. You either capture the return value and use that to read and close the file, *OR* you provide a block with the IO variable a reference to the file. In the latter case, when you reach the end of the block, the file is closed automatically. Second, the variable "L" is a constant. I'm not sure you want a constant. Below are two bits of code that do what you're trying to do, each using one of the distinct ways to use the open call. ==== File.open('ReportTxt.txt', 'r') do |l| while c = l.getc puts c.chr end end l = File.open('ReportTxt.txt', 'r') while c = l.getc puts c.chr end l.close ==== Do you mind my asking what resource(s) you're using to learn Ruby? I hope that helps, Eric ==== LearnRuby.com offers Rails & Ruby HANDS-ON public & ON-SITE workshops. Ruby Fundamentals Wkshp June 16-18 Ann Arbor, Mich. Ready for Rails Ruby Wkshp June 23-24 Ann Arbor, Mich. Ruby on Rails Wkshp June 25-27 Ann Arbor, Mich. Ruby Plus Rails Combo Wkshp June 23-27 Ann Arbor, Mich Please visit http://LearnRuby.com for all the details.