added lines to flush stdout buffer