Note this also features more robust error checking. The code you posted fails to close the file, among other issues.
I would not recommend using yewbie's code, it is terrible.
Heh, I am not going to defend what I posted as good code but the tutorial specifically said that when ifstream goes out of scope it cleanly closes the file.
And most of what is posted is directly from the tutorial. ( Edit: not that tutorials are to be trusted )
Much like the OP I only needed it for a couple of config lines and it worked fine for that.
Your code looks much better.