collects input and prints output