log errors for fwrite