[PATCH v2 1/2] programs/cmd: test that read is successful before using its result