<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def readfile(filename, binary=False):
 """ Reads the contents of the specified file. `filename` Filename to read. `binary` Set to ``True`` to indicate a binary file. Returns string or ``None``. """


    if not os.path.isfile(filename):
        return None

    try:
        flags = 'r' if not binary else 'rb'
        with open(filename, flags) as _file:
            return _file.read()

    except (OSError, IOError):
        return None