Added printing, fixed some major bugs with while loops