I don't think that you should be doing this. If you want unbuffered output, why don't you write to stderr?