Why does 'w' work for reading sometimes and sometimes doesn't?

  File.open("#{base}-shuffled#{extension}", "w") do |file|
    File.readlines(filename).shuffle.each do |line|
      file.puts line.chomp
    end
  end

This line of code works whether you put ‘w+’ or not. The SO Post says that ‘w’ is ‘write only’ so why can I do File.readlines?

Commenting only so I can follow this thread. This is something I definitely want to get better at. I don’t really get what is the difference between “w” and “w+”. I understand “w+” you’re supposed to be able to read and write but I tried to read while writing and didn’t seem to work.

I’m not sure why that would be. I wonder if it has to do with the file’s permissions in the operating system? Keep the question in the back of your mind and ask the TA’s when you get to the in person course! I know it can be a little frustrating when things don’t work as documented.