We consider atoms traversing a cavity filled with an optical field. When the atoms are well detuned from the optical resonance the output momentum distribution of the atoms is found to be a sensitive probe of the photon statistics of the light field. Near resonance spontaneous emission smears the diffractive peaks. We obtain a good fit to the experimental data of Gould et at. (1991). As the atoms pass through the optical field they impart a position-dependent phase shift to the field. By making a quadrature phase measurement on the optical field a position measurement of the atom is achieved. We show that it is possible to prepare the atom in a 'contractive state' which beats the standard quantum limit for position measurements.