When an electric current flows in a wire it creates a magnetic field around the wire
By winding the wire into a coil we can strengthen the magnetic field by concentrating the field lines
If this wire is wound around a soft magnet, such as an iron, then an electromagnet is made
The electromagnet is magnetic only when current flows through the wire