replace not working MessageBox with writing to fstream