used putc/fgetc isntad of scanf