You can probably speed up file I/O a bit by reading x number of bytes plus the rest of the current line, then splitting on line endings and running through the lines in array form. This allows you to scale memory use to whatever your system can handle, unlike line-by-line reading or reading the entire file.