I'll bet that loose wire was the neutral or grounded (not ground) conductor. That left the electricity looking for another path back to the transformer. The shield on the cable was it.
Yes it was dangerous. Glad you found a good sparky to fix it.
"You can follow me, but it's gonna hurt"