shell script to transform the input file into a bunch of "good" files