Ensured consistent format and comments are clear. Added the functality to reject file types that are not .txt and displays an error message.