Writing pairs to file.