Quantum measurement of a system can change its mean energy as well as entropy. A selective measurement (classical or quantum) can be used as a ‘Maxwell's demon’ to power a single-temperature heat engine by decreasing the entropy. Quantum mechanically, so can a non-selective measurement, despite increasing the entropy of a thermal state. The maximal amount of work extractable following the measurement is given by the change in free energy: W(non-)selmax = ∆Emeas - TBath∆S(non-)selmeas. This follows from the ‘generalized 2nd law for nonequilibrium initial state’ (Hasegawa et al 2010 Phys. Lett. A 374 1001-4), an elementary reduction of which to the standard law is given here. It is shown that Wselmax - Wnon-selmax is equal to the work required for resetting the memory of the measuring device and that no such resetting is needed in the non-selective case. Consequently, a single-bath engine powered by either kind of measurement works at a net loss of TBath∆Snon-selmeas per cycle. By replacing the measurement by a reversible ‘pre-measurement’ and allowing a work source to couple to the system and memory, the cycle can be rendered completely reversible.