fix to use O_WRONLY flag.