added line buffered and binary mode