must write files in binary mode or windows will append end of lines