def count_lines(filename):
    """Counts and returns how many non empty lines in a file there are."""
    with open(filename, 'r') as f:
        lines = [x for x in list(f) if x.strip()]
    return len(lines)