Maxwell's equations
This equation says, that in every volume the sum of the magnetic field lines that go in equals the sum of the magnetical field lines that go out. This means that the magnetic field lines must be closed loops. Another way of saying this is that the field lines cannot start from somewhere.