Fix index for getchar