Consistently flush before closing Writer