use io; use strings; use fmt; export type error = !(str | io::error); export fn writerecord(w: io::handle, record: []str) (void | error) = { let sep = ""; for (const field .. record) { const pfield = strings::replace(field, "\t", ""); defer free(pfield); fmt::fprintf(w, "{}{}", sep, pfield)!; sep = "\t"; }; fmt::fprintln(w)!; }; export fn writerecords(w: io::handle, records: [][]str) (void | error) = { for (const record .. records) { writerecord(w, record)?; }; };