Question: What states that the system doing work always loses some energy as waste heat?
Sentence: While heat can always be fully converted into work in a reversible isothermal expansion of an ideal gas, for cyclic processes of practical interest in heat engines the second law of thermodynamics states that the system doing work always loses some energy as waste heat.
Answer in sentence: yes