modify flush() implmentation on Windows