I was just anticipating, as it's the sort of thing you ask
For the Pedantic, Rule 17 is nowadays actually Rule 5.9.1 onwards, governing the use of Headlights, thus;
5.9.1 Dimming Headlight
Except when the engine is approaching and passing over a public crossing at grade, dim the headlight during any of the following conditions:
1. At stations and yards where switching is being done.
2. When the engine is stopped close behind another train.
3. In non-signaled territory, when the engine is stopped on the main track waiting for an approaching train.
4. When approaching and passing the head end and rear end of a train on the adjacent track.
5. At other times to permit passing of hand signals or when the safety of employees requires.
5.9.2 Headlight Off
Turn the headlight off under either of the following conditions:
1. When the train is stopped in the clear of the main track to meet a train. However, an extinguished headlight does not indicate to an opposing train that a train is clear of the main track.
2. Within block system limits, when the train is stopped on the main track to meet a train approaching on the same track.
5.9.3 Headlight Failure
If the headlight on the train fails, ditch lights must be on, when so equipped. Headlight failure must be reported to the train dispatcher.
At night, if headlight and ditch lights fail to operate and no other unit can be used as the lead unit, continue movement with a white light displayed on the lead unit. Stop the train before each public crossing, so a crew member on the ground can provide warning until the crossing is occupied, unless:
Crossing gates are in the fully lowered position. or No traffic is approaching or stopped at the crossing.
5.9.4 Displaying Headlights Front and Rear
When engines are moving, crew members must turm on the headlight to the front and rear, but may dim or extinguish it on the end coupled to cars.