Add the following line after webApp.WebConfigModifications.Add(modification);

webApp.WebConfigModifications.Clear();

it clears all the non-required modifications from the object.