<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def echo(topic_name, num_print=None, out=sys.stdout, host=jps.env.get_master_host(), sub_port=jps.DEFAULT_SUB_PORT):
    '''print the data for the given topic forever
    '''
    class PrintWithCount(object):

        def __init__(self, out):
            self._printed = 0
            self._out = out

        def print_and_increment(self, msg):
            self._out.write('{}\n'.format(msg))
            self._printed += 1

        def get_count(self):
            return self._printed

    counter = PrintWithCount(out)
    sub = jps.Subscriber(
        topic_name, counter.print_and_increment, host=host, sub_port=sub_port)
    try:
        while num_print is None or counter.get_count() < num_print:
            sub.spin_once()
            time.sleep(0.0001)
    except KeyboardInterrupt:
        pass