Reset errno prior to use; set bufsz to LINE_MAX.