How to calculate 3D line-line interesction?

I used this function for intersection of finite line segments and it worked perfectly:

http://paulbourke.net/geometry/pointlineplane/L3D.py