import codecs


def _open_file_with_cache(filename):
    """
    Reads the input file and returns the result as a string.

    This caches opened files to ensure that the audit functionality
    doesn't unnecessarily re-open the same file.
    """
    try:
        with codecs.open(filename, encoding='utf-8') as f:
            return f.read()
    except (OSError, IOError):
        return None