Basic interrupts with optical encoder wont work when serial.println

Hey guys ive written a small program that uses interrupts to sense an optical encoder turning. basically what i want is to increment and print a counter everytime the interrupt pin gets a signal from the encoder. i have used AVR c coding as im trying to move away from arduino coding but when i use serial print to print the counter the screen starts printing garbage and the whole program stops running. The program i have added just simply blinks an LED on and off when the interrupt occurs. i added a counter and the serial.println but then is went crazy. i understand the serial.print uses interrupts itself and misght not work if it is used inside the interrupt service routine. but i have put it in the main loop so why wont it work?

# include <avr/io.h>
# include <util/delay.h>
# include <avr/interrupt.h>

int counter = 0;
int main(void){
  DDRB = 0b00000001;                     //set pins 0 and 1 to output on port B
  DDRD = 0b00000000;                     //ser all pins on port D to input
  PORTD = 0b00000100;                    //enable internal pulup resistor
  EIMSK = 1 << INT0;                     //External interrupt mask register
                                         //this is the interupts enable bit for INT0 pin
  sei();                                //enable global interupts, This is setting the I bit in the SREG to 1
  EICRA = 0 << ISC01 | 1 << ISC00;      //(EICRA) External interupt control register A for INT0 (ISC) Interupt sensor control bit,
                                        // 4 bits (namely ISC00,ISC01,ISC10,ISC11) are set which control how interupts react, rising edge, falling edge, any logical change etc
                                        //Note that only two are set per interupt pin
  while (1)

  PORTB ^= 1 << PINB0;
  counter = counter +1;
  reti();                              //Signal end interrupts

Shouldn't counter be declared as volatile because it is changed inside the ISR ?

Pins 0 and 1 are dedicated to serial.

Oh snap haha how could i have missed that. My bad. How will i then print the incriminating counter on the serial monitor? is there another way?

  DDRB = 0b00000001;                     //set pins 0 and 1 to output on port B
  DDRD = 0b00000000;                     //ser all pins on port D to input
  PORTD = 0b00000100;                    //enable internal pulup resistor

What Arduino are you using?

If you used the ordinary Arduino programming system you would not get tripped up by different pin numbering arrangements.

Your comment regarding portB does not match the code. And you probably should not interfere with pins 6 and 7 of portB

On the Uno port D0 and D1 are the Rx and Tx pins. You should not set all of the pins - only the ones you want using & and | as appropriate. In fact on an Uno none of the ports has all 8 pins free.

I presume you are aware that external interrupts 0 and 1 operate on the Arduino pins 2 and 3.