Read serial data using C++ (in Linux)

Ok I cut all the things out the the getChar function that I didn't need and I'm left with:

char Serial::getChar() {
      
			if (bufferIndex > 0) {
				// Yes, so grab the byte we need and shift the buffer left
				char c = buffer[1];
				for (int j = 1; j < (bufferIndex + 1); j++) {
					buffer[j] = buffer[j + 1];
				}
				bufferIndex--;
				// Send back the first byte in the buffer
				return c;
			}
			// If the port is actually open, grab a byte
			if (fd != -1) {
				// Return the byte received if it's there
				int n = read(fd, &temp[0], 1);
		
						return temp[0];
					
				}
				else return -1;
			
		}

When I run this code:

#include "./include/serial.h"
#include <string.h>

int main(int argc, char** argv) {


	char xd= 'a';

	Serial port;
	
	port.dev = "/dev/ttyUSB0";

	port.baud=9600;
	port.dataBits = 8;
	
	int result = port.initPort();


	printf("Init returned: %i\n", result);


    
	while (result != -1) {

	xd = port.getChar();
        printf("%c" ,xd);
				
			}

	port.closePort();			
	return -1;
}

I get all the letters sent from my arduino repeated like the following:

DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaattttttttttttttttttttttttttttttttttttttttttttttttaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:::::::::::::::::::::::::::