As illustrated by the Maxwell demon and its sequels, feedback can be utilized to convert information into useful work. The recently developed fluctuation theorems turn out to be a powerful tool to analyze the energetics of feedback controlled systems. Using these theorems, we devise a method for designing optimal feedback protocols for thermodynamic engines that extract all the information gained during feedback as work. Our method is based on the observation that in a feedback-reversible process the measurement and the time-reversal of the ensuing protocol both prepare the system in the same probabilistic state. We illustrate the utility of our method with two examples of the multi-particle Szilard engine.