In a steam engine, water is heated in a boiler until it changes into steam. This high-pressure steam is introduced into a closed cylinder that contains a free-moving piston. The steam forces the piston down. The resulting water takes up only a fraction of as much space as the steam did, so a vacuum is formed in the cylinder. This causes the piston to be drawn up. At the top of the piston’s stroke, a fresh supply of high-pressure steam is introduced into the cylinder. The engine repeats its cycle. A flywheel attached beneath the cylinder changes the reciprocating motion of the engine to rotary motion.