From: Michael Davis Date: 2001-11-21T03:44:35+09:00 Subject: [ruby-talk:25937] RE: File access modes File.open("counter", "w+") - creates the file File.open("counter", "r+") - opens the file for reading and writing. -----Original Message----- From: HarryO [SMTP:harryo@zipworld.com.au] Sent: Monday, November 19, 2001 10:12 PM To: ruby-talk ML; undisclosed-recipients: ; Subject: [ruby-talk:25890] File access modes I wanted to write some code that would update a counter stored in a file. The following code works just fine ... File.open("counter", File::CREAT | File::RDWR) do |f| f.flock(File::LOCK_EX) count = f.gets.to_i f.rewind f.puts count + 1 end .... but I orginally wrote the File.open() as ... File.open("counter", "w+") and the f.gets seemed to return an empty string every time, irrespective of whether the file already existed, and even if I put an extra f.rewind before it (although, I thought that was redundant). Is there a string-style mode that's equivalent to the specific mode flags I've use above?