Omitting print statements stops program working