Try also
Code:
outfile.precision(4);
though it should make a difference.

As a minor note, you might want to use std::fixed as well. No idea why it doesn't work for you