int main(blahblahblahwhatever) { fin routines. One character at a time. ch="0"; commaCount="0"; maxComma="256"; // you define this linecount=0; cntfname="1"; // you define this cntlname="12"; // you define this cntdep="24"; // you define this if (ch==","){ if (commaCount==maxComma) { commaCount = 0; linecount++;} commaCount++; } else { if (cntfname==commaCount){ fout << ch;} if (cntlname==commaCount){ fout << ch;} if (cntdep==commaCount){ fout << ch;} } linecount++; }