X3 - headlight switches and wiring are a known problem on these trucks. Also check the spade terminals on the switch - when I had headlight problems, some of the terminals on my switch were still attached on the switch but were loose. Fix and/or replace switch and harness as needed - when I replaced my switch years ago, my replacement switch included a connector/pigtail. I suggest you then look into relay harnesses to power your headlights off the battery and take the load out of the switch - the switch is then used only as a relay trigger. There are a number of threads on the relay mod - easily found using the search feature. Some of them even have wiring diagrams if you want to tackle making your own harnesses. There is also the "sport headlights" mod where you upgrade to the late 2nd-gen sport headlights (2 bulbs per side - relay harnesses definitely required) - also found using the search feature.