def reader(f, buffer):
    """Utility function runing in a thread
    which transfers any lines from the 
    pipe `f` into the list `buffer`
    """
    while True:
        line = f.readline()
        if line:
            buffer.append(line)
        else:
            break
