Changing readf (" %s", &second); to readf (" %s ", &second); is likely to fix it (untested). There is a "\n" symbol left in buffer from last entry (which gets read by `getc`)