The artifacts are due to the way you're controlling the loop. Check what std::istream::get actually returns. Note that your cyphertext already has an extra character in it so your encrypt is part of the problem. Just out of interest, as you're programming in C++ and not C: - get rid of all the explicit opens/closes, you don't need them, destructors are wonderful things - instead of letting a user crash your code by entering a filename of longer than 200 characters use std::strings and std::getline - don't use macros, a pair of functions would have worked as well and enabled you to use the same code for encryption and decryption (the same goes for C BTW) I'd also consider splitting the encrypt/decrypt bits of your code from all the guff asking for filenames, then you'd have something you can unit test without all the nuts ache of entering files all the time. Cheers, Ash