I have a 1940s house, and I am adding light fixture to an upstairs bedroom. I am replacing a wall light fixture that was plugged into a switched outlet with a fixture that is hard wired. Currently the circuit is wired as follows:

The cable from the breaker panel goes to the outlet box, then a another cable goes from there to the wall switch. The switch is at the end of the circuit. The two black wires in the receptacle box are twisted together. I believe the white wire from the wall switch goes to the brass screw on the receptacle, and the white the wire from the breaker panel to the silver screw on the receptacle.

I installed the new fixture on the wall and ran a cable down to the receptacle box. (I do have access to the framing inside the wall, where the receptacle is, through a closet.) The problem is I can't figure out how to add the light fixture to the circuit.

As a test, the first thing I tried was (before I installed it) wiring the light fixture directly to the other two screws on the receptacle. When I turned the power back on and used the wall switch, the light when on and off like it should. But when I installed the fixture, ran the cable down inside the wall, and hooked it up the same way, the breaker immediately tripped when I tried to turn the power on. I double checked the wiring at the fixture and it looks right, black to black and white to white, nothing loose.

I tried to figure out another way to hook it up. I think at one point I had the black wire from the fixture connected to the silver screw on the receptacle, and the white wire connected to the white wire to the panel, and the wall switch operated the wall fixture, but only if I plugged a table lamp into the outlet and turned it on. When I turned out the table lamp, out went the wall light.

I'm really scratching my head over this one. I admit I'm not a professional electrician, but I have done many basic jobs like this around the house before. In fact, I did exactly the same job in another bedroom when I renovated it. I added a new ceiling box and fixture, wired it into a switched wall receptacle, and it worked perfectly.

What should I do here?