Any electrical intermittancy is almost always a wire issue that can require full going over of the wiring. Fortunately, not much wiring on these bikes. I do not think it is the bolt problem. That is secure and if it was the cause, it would be consistent, not intermittent.
There are two places to check. It can be a corroded/shorted connector or bad ground.
Before going into any of it though, try and get a wiring diagram copy printed. Find the problematic component and follow the wires to and from it. This can sometimes point right away to a connector or another common area, as well as help focus on just what can be potential causes. A roadmap to diagnosis so to speak.
A voltmeter will be your friend. Take that light, test resistance to ground, resistance to battery. You will see one off, or will see nothing. Resistance is probably bad connector, nothing problematic is usually loose. Just go through and inspect. Many a bike has been rendered inoperative thanks to a corroded connector, the killer of rectifiers.
The loose connection, will example my nighthawk. If it is a bad ground, one thing that can clue that is if neutral vs not in neutral changes the problem (with lights and starting) because in my case, grounding bolt was loose, the one up by the coils. As result, my lights were instead taking funny wiring path and grounding through the neutral light switch.