add 'os.O_RDWR' mode for output file