How can you safely free a wire neeeded to hook into a fixture when it is attached to another wire connected at an end cap and leading into the attic?

Turn the circuit breaker to the off position. Then unhook the wire that you need. Those end caps are called marrettes. If you a really sketched out about doing this then you should go to library and find out how to do it. There is no danger of getting electrocuted, but there is a fire hazard associated with improperly installed fixtures! Also, it begs the question, was the wire there for a previously installed fixture or are you going to steal the wire that's being used to power something in the attic?