Regarding this really useful part of the std lib, I warmly suggest to also benchmark the final code against a similar operation done in Perl or Python2.x. Such tests very often show performance bugs/problems.
Python code for the test is really simple:
file("filename.txt).read()
Bye,
bearophile