added new convenience method ‘writeOutAndFlush’