How can we say that work done by carnot engine in a cycle equals net heat released into it even when it is operated b/w 2 bodies and not 2 reservoir? When a carnot engine is operated between 2 reservoir then after each cycle it return to its initial state so change in internal energy is zero and so work done by it equals net heat released into it. But suppose it is operated between 2 bodies so when higher temperature body releases heat into carnot engine and the engine releases heat into lower temperature body the temperature of bodies will change (unlike the reservoir). So how can work done by carnot engine still equals net heat released into it as given in the example 13.6 of book 'Concepts in Thermal Physics'?
 A: I think the question is asking how—if the Carnot engine's original state was at $T_\mathrm{high}$, corresponding to the initial temperature of a high-temperature finite body—can the engine return to this original state after a cycle that removes heat from that body, bringing it to $T_\mathrm{high}-\delta T$. Is this correct?
If you wish, in the idealization of the Carnot engine (already quite far from reality, as this engine completely lacks friction and operates infinitely slowly, for example), you could also assume that its thermal mass is negligible. Thus, returning to the original state doesn't place any requirements on the actual engine's physical temperature.
In addition, you could dynamically update the (decreasing) Carnot efficiency as the high-temperature finite body cools down and the low-temperature finite body heats up with continued cycling during engine operation.
In all cases, the engine isn't a store or sink of energy or mass, so the net heat input must equal the work output. There's just no other possible mode of energy transfer.
But yes, the use of finite bodies instead of idealized infinitely large reservoirs places another burden on the idealization, since there's no way the engine will ever get to $T_\mathrm{high}$ again.
Does this get at what you're asking about?
A: The first law  of thermodynamics for a closed system dictates that the net work done by any heat engine over a cycle, not just the Carnot cycle, equals the net heat added. It doesn't matter if the heat transfers occur with thermal reservoirs or bodies whose temperatures can change. It's simply a matter of conservation of energy. What does matter is the maximum efficiency of a heat engine cycle necessitates that the cycle be both reversible and the heat transfers occur with two fixed thermal reservoirs.
By definition, the Carnot heat engine cycle is a reversible cycle that operates between two fixed thermal reservoirs. If the heat transfers occur with only two bodies whose temperatures can change it is not a Carnot heat engine cycle. For one thing, the heat transfers will not be reversible as the heat transfers will occur over finite temperature differences between the system and surroundings.
To make the cycle reversible, one can replace the two bodies by transferring heat with an infinite number of bodies that are thermal reservoirs whose temperatures vary between the initial and final temperatures of the two bodies. This is what section 13.7 of your book is referring to when it says
"Therefore we would like to generalize our treatment so that it can be applied to a general cycle operating between a whole series of reservoirs and we would like the cycle to be either reversible or irreversible". One can do this for reversible heat transfers with the multiple reservoirs, but the generalization is not a Carnot cycle and its efficiency will be less than the Carnot cycle.
One can see this from the the following equation for the Carnot efficiency
$$\eta_{C}=1-\frac{T_C}{T_H}$$
Now, if instead of two fixed temperature bodies, we have an infinite series of reservoirs in which the temperature of the hot body reservoirs vary between $T_H$ and $T_{H}-\Delta T$ and the temperature of the cold body reservoirs vary between $T_C$ and $T_{C}+\Delta T$, where $T_H$ and $T_C$ are the initial temperatures of the hot and cold body reservoir, respectively. Then the efficiency would be, using the average high and low temperatures of the reservoirs,
$$\eta=1-\frac{T_{C}+(T_{C}+\Delta T)/2}{T_{H}+(T_{H}-\Delta T)/2}=1-\frac{T_{C}+\Delta T/2}{T_{H}-\Delta T/2}$$
Which, as you can see, is less than the Carnot efficiency.
Hope this helps.
A: The process you are describing is not a cycle.  So depending on where you start your process, the final internal energy of the working fluid (ideal gas) may not be equal to the starting internal energy of the working fluid, and the working fluid will have done a different amount of work than the amount of heat it received.  But, if you start your first cycle on one of the adiabats, and at the same final temperature that the two reservoirs and working fluid attain, the change in internal energy of the working fluid will be zero, and the heat will exactly match the work.  In any event, what we usually assume (tacitly) in a case like this is that the change in internal energy of the working fluid is negligible compared to the overall work and heat.
