<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_debug_log(self, file_path):
 """ Write the debug log to a file """

        with open(file_path, "wb+") as fh:
            fh.write(system.get_system_info().encode('utf-8'))
            # writing to debug stream
            self._debug_stream.seek(0)
            fh.write(self._debug_stream.read().encode('utf-8'))
            fh.write("The following errors occured:\n".encode('utf-8'))
            for error in self._errors:
                fh.write((error + "\n").encode('utf-8'))
            for k, v in self._error_dict.items():
                if len(v) > 0:
                    fh.write(("Error(s) in %s with formula %s:\n" % k).encode('utf-8'))
                    for error in v:
                        fh.write((error + "\n").encode('utf-8'))