  We find a solution to $4D$ Einstein-Maxwell theory coupled to a massless
dilaton field describing a Melvin magnetic field in an expanding universe with
'stiff matter' equation of state parameter $w=+1$. As the universe expands,
magnetic flux becomes more concentrated around the symmetry axis for dilaton
coupling $a<1/\sqrt{3}$ and more dispersed for $a>1/\sqrt{3}$. An electric
field circulates around the symmetry axis in the direction determined by Lenz's
law. For $a=0$ the magnetic flux through a disk of fixed comoving radius is
proportional to the proper area of the disk. This result disagrees with the
usual expectation based on a test magnetic field that this flux should be
constant, and we show why this difference arises. We also find a Melvin
solution in an accelerating universe with $w=-7/9$ for a dilaton field with a
certain exponential potential. Our main tools are simple manipulations in $5D$
Kaluza-Klein theory and related solution generating techniques. We also discuss
a number of directions for possible extensions of this work.
