#!/usr/bin/python3

import subprocess


def run_command():
    p = subprocess.Popen("./command.py",
                         stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT,
                         universal_newlines=True)  # this converts \r into \n #fail

    for line in iter(p.stdout.readline, ""):
        yield line, p.poll()

    yield "", p.wait()


for l, rc in run_command():
    print(l, end="", flush=True)
