issue 384 patch suggested by vijinho

Line 146, adding buffer flushing