set return variable to NULL if the read fails