Try setbuf() hack to preserve the output