Added unbuffered output; Outlined buffered output