Fixed file open to w+ mode to allow read and write