The temperature-dependent linewidth of excitons in semiconductor quantum wells due to the interaction of the exciton with LO phonons is studied with use of perturbation theory for the exciton-phonon interaction and by assuming an infinite-barrier-quantum-well model. The interaction is taken to be of the Fr\"ohlich form, and the scattering of the exciton to both bound and scattering states of the interacting electron--heavy-hole system has been taken into account. The dependence of the linewidth on the quantum-well width and on the choice of the heavy-hole mass is discussed, and comparison is made with available experimental data. The effects of the confinement of the optical phonons on the exciton linewidth are also studied and are found not to alter substantively the results for the dependence of the linewidth on the quantum-well width.