Iterate over the length of the string and not the size of the alphabet. For example


for ( int i = 0; i < line.length(); i++ ){
//replace character at position i in line with your encryption...