Made write and close functions follow a polite calling convention