Portable C version of Linecounter