Rice forms sticky masses in the stomach that remove gastric mucus as they move through peristalsis, exposing the stomach lining to damage from acid and pepsin. This mucus removal can cause heartburn or ulcers. However, drinking water with rice can prevent this by turning the rice masses into a slurry rather than sticky masses, avoiding excessive mucus removal.