def count_lines(filename):
    """
    Count the number of lines in a file.
    :param filename:
    :type filename:  str
    :return:
    :rtype: int
    """
    n = 0
    with open(filename, 'rb') as fh:
        for line in fh:
            n += 1
    return n
