Added flushing of stdout to measurement code
Moved flushing of stdout in measurement code