We have detected Mg impurities in YBaCuO (YBCO) high-critical-temperature superconductor films on MgO by means of Rutherford backscattering spectroscopy. We find that the critical temperature T c decreases by ~10 K for inclusion of 5% Mg in the film as well as in the bulk YBCO with Mg impurity, when H impurity content is <10% and no other impurity other than C is present in the films. It is suggested that interdiffusion takes place during the film deposition leading to inclusion of such a small amount of Mg in the film. Use of a very fast deposition method, i.e., pulsed-laser deposition, buffer layers and different substrate may suppress the Mg interdiffusion.