replace getc with readc