adding O_RDWR flag in the open()
According to the manual of open: "The argument flags must include one of the following access modes: O_RDONLY, O_WRONLY, or O_RDWR."
According to the manual of open: "The argument flags must include one of the following access modes: O_RDONLY, O_WRONLY, or O_RDWR."