Why do moths and some flies fly towards light?

I have my window open and a light on inside. Outside it is dark, I was wondering why all the moths and daddy long-legs all fly towards the light.

Thanks x
13 answers 13