Check return-value of ref_sys_read(), and only search through the buffer that has been read.