write matches to file