Added write-out for distances.