def getline(fp):
    """
    Reads a line from fp into string s, and trims away any trailing whitespace
    This function works with \r and \n and \r\n and even \n\r as EOL
    (the latter occurs on MacOs 8/9, because MPW swaps \r and \n)
    RC: 1 = line successfully read; 0 = EOF or error

    :param file fp:
    :return str:
    """
    s = fp.readline()
    if s:
        return s.strip(), True
    return '', False