On the way to prove 1st law of thermodynamics, you consider a system having initial energy E1. Then, you supply heat q to the system. Some part of the applied heat is used for doing work. Then, again you consider the final energy (E2) of the system to be: E2=E1+q+w where w is the work done. We all very well know that the work is done by the heat applied. If we add both heat applied and work done to the final energy, isn't the work done counted twice. I mean to say that the heat energy wasted in the work done is also consisted in q so why is there need to add w in the final energy E2.