Should you not use `res` (i.e. the length of the recovered data) instead of assuming it's exactly that long?