added line buffering