Monday, January 8, 2007 10:40 PM
You can't really just remove a subset of bytes from a file the way (that I understand) you are thinking: you'll have to write a new file with the material before and after the offending line, and to get the "after" material, you have to read it somehow. In other words, you can't just say "without continuing to read the rest of the file", as it doesn't make any sense. This is with respect to any general programming language.
If you are worried about performance in general, what you could probably do is change over from line-level file reads to byte-block level file reads once you find the line you want (or with even better code -- and depending on the nature of your real problem -- you could work entirely in byte-block level reads ... though you'd have to account for the possibility of the byte block only partially capturing the line you are looking for).