Straight from the 240sx.org FAQ's:
Headlight Flickering
Question:
My passenger side flip up headlight flickers and sometimes just doesn't work. I have checked to make sure the connection to the headlight is OK and best as I can tell the filament is OK. Is this a common problem and what can I do to fix it?
Answer:
There are two headlight retracting relays, one for each headlight. One of them may be defective causing your problem. The relays are located on the driver's side of the engine up front under the air filter air box. You might try swapping them to see if the problem goes over to the other headlight.
Give it a check/look and see what happens
