script should flush its output into the file periodicially