On some stream libraries failbit is not set when trying to read past EOF. Instead, always exit the copy loop when gcount() is zero. Change-Id: Ied2a6a366ade185426c34ef58795e66472dc71dc