check if fopen succeeds before trying to write to the log...