Moved print loop outside of process loop