We consider a Szilard engine in one dimension, consisting of a single particle of mass m, moving between a piston of mass M , and a heat reservoir at temperature T . In addition to an external force, the piston experiences repeated elastic collisions with the particle. We find that the motion of a heavy piston (M ≫ m), can be described effectively by a Langevin equation. Various numerical evidences suggest that the frictional coefficient in the Langevin equation is given by γ = (1/X) √ 8πmkBT , where X is the position of the piston measured from the thermal wall. Starting from the exact master equation for the full system and using a perturbation expansion in ǫ = m/M , we integrate out the degrees of freedom of the particle to obtain the effective Fokker-Planck equation for the piston albeit with a different frictional coefficient. Our microscopic study shows that the piston is never in equilibrium during the expansion step, contrary to the assumption made in the usual Szilard engine analysis -nevertheless the conclusions of Szilard remain valid.