When iron rusts, it combines with oxygen from air to form iron oxide (Fe2O3). Since oxygen atoms add to the iron, the total mass increases. This follows the law of conservation of mass - the nail's weight increases by the mass of oxygen atoms that bond with iron.