Write the provided data to the file.

        `filename`
            Filename to write.
        `data`
            Data buffer to write.
        `binary`
            Set to ``True`` to indicate a binary file.

        Returns boolean.

def writefile(filename, data, binary=False):
    """ Write the provided data to the file.

        `filename`
            Filename to write.
        `data`
            Data buffer to write.
        `binary`
            Set to ``True`` to indicate a binary file.

        Returns boolean.
        """
    try:
        flags = 'w' if not binary else 'wb'
        with open(filename, flags) as _file:
            _file.write(data)
            _file.flush()
            return True

    except (OSError, IOError):
        return False