Changed all 'r+' to 'w+'

The problem with r+ is that it does not create a new file if the file does not exist.