When trying to perform the copy operation, your
infile
has already been closed. You must re-open the input file before copying or don't close it (rewind the stream in this case).
You are also not performing any write operation to the output file. It seems that this operation is missing after the second read line
while(infile.get(in_char))