Handle the return value to fwrite properly