Issue #2489: Fix bug in _copy loop that could consume 100% cpu on EOF.