def openfile(fname):
    """
    Opens the file handle of file `fname`.

    """
    if hasattr(fname, 'readline'):
        return fname
    try:
        f = open(fname)
    except IOError:
        raise IOError("No such file: '%s'" % fname)
    if f.readline()[:2] != '\\x':
        f.seek(0, 0)
        return f
    f.close()
    raise NotImplementedError('Wow, binary file')
