passing a NULL pointer for the string to write is an error