If you use the extraction operator ">>" to read from the file then it will not grab the white space. You'll have to add a space in between words in your code yourself but it should do what you want.
Right now your code doesn't have any effect on the file. Are you just experimenting?