getchar() moved to if