Add flush calls after writes to stdout from inside of phantom

Resolves issue #16