steam era

i was watching a video of the NW coal trains coming out of West Virginia on the mountains.1st question, why was the lead loco puffing out black steam and the back-up loco was puffing out white steam? And, how did they light the headlight with electricity?

The colour of the “steam” that comes from the stack is a mix of smoke from the fire and exhaust steam from the cylinders.
A good fire with proper combustion produces little smoke, and so what comes out of the stack is mostly steam (white). A poorly fired engine or one where the fireman (fireperson??) has just dumped a load of coal onto the fire has poor combustion and produces black smoke. Another factor is the qulity of the coal, some produces more smoke than others.
Oil fired engines have their flues cleaned by resting a shovel filled with sand on the firebox door. the draw pulls the sand through the flue whare soot is knocked off. This sometimes creates a load of black smoke temporarily.

To light the headlight & cab lights & marker lights the engine has a small steam powered generator that produces electricity.

thank you hugh for your answer, as y’all say in england…BLIMY…HAVE A GOOD DAY!