Add flush calls after writes to stdout from inside of phantom