Let me give an example of why it's important that writelines
iteratively writes. For:
rows = (line[:-1].split('\t') for line in in_file)
projected = (keep_fields(row, 0, 3, 7) for row in rows)
filtered = (row for row in projected if row[2]=='1')
out_file.writelines('\t'.join(row)+'\n' for row in filtered)
For a large input file, for a regular out_file object, this will work.
For a codecs.StreamWriter wrapped out_file object, this won't work,
because it's not following the file protocol that writelines should
iteratively write.