r+ will open the file and give you read-write access iff the file is exists. w+ and a+ create new files if it doesn't exist, unlike r+. (w+ truncates, a+ appends) Siddarth On Sun, May 9, 2010 at 7:48 PM, David Chapman <ideabolt / gmail.com> wrote: > Hi folks, > > New to Ruby, with little previous coding experience. Anyway, trying out > a few examples from a tut: > > junkfile = File.new("junk", "r+") > junkfile.write ('junk line 1') > junkfile.write ('junk line 2') > junkfile.rewind > puts junkfile.readline > puts junkfile.readline > > > This is the output: > > No such file or directory - junk > C:/DATA/FILE/CODE/RUBY/prgs/junktest.rb:1:in `initialize' > Press ENTER to close the window... > > What am I doing wrong? > > Thanks. > -- > Posted via http://www.ruby-forum.com/. > >