Refactored gets() and printf().