he whole idea is unsound. stdio buffers ahead, so you cannot just abandon the stream and start another one. If you cannot find a way to use a single FILE pointer, you are better off read-ing char by char (to end-of-line?) and sscanf-ing.