you might want to use the function member function 'get(char *, int)', (or since you seem to be inputting a single character at a time, 'get(char &ch)') to read in data.
might I suggest you read in a few more char's than just one at a time, like say 1000 (or more, depending on file size), and encoding the whole buffer, it will go much quicker
// Read Char //
// Encode Char //
int_buffer = int(char_buffer); //casting isnt necessary here, char_buffer += -1, or simply char_buffer-- will suffice
// Write Char
char_out = char(int_buffer);
cfile << char_buffer;