added missing O_BINARY to open().