fix regex and write coords to file