Question: what is the difference between r+ and w+ modes?
Answer: What is the difference between these two modes of writing to a file? r+ simply opens the file for both reading and writing. w+ opens the file for reading and writing, but discards the contents of the file or creates the file if it doesn't exist.