fixed the distance code so that the xy files are read correctly. also changed output directory so its always relative to your specification of the input directory