You've got the file stream method close() called for both of your files...in your while loop. So it goes through the first round, and then closes the file. All other operations on the files will fail, because there is no longer an association of the stream with the file.
Move the infile.close() and outfile.close() statements to the outside of the while loop.
And you may also want to use the get() method instead of the stream extraction operator >>, and use a test of whether or not the end of the file has been reached as your while-loop continuation test:
CODE
while (!infile.eof()) {
infile.get(ch);
...
get(ch) will get a single character from the file stream; the >> operator is generally used to extract formatted data (floats, ints, etc).
You should probably also have a check to ensure that the file was opened successfully, before you try to read from it.
Hope that helps
This post has been edited by jjhaag: 15 Oct, 2007 - 11:37 PM