in reply to Split a file based on column
Update: I was trying to think of something along davido's answer where you only opened the output file once and not repeated opening and closing with every loop iteration.