Made changes to the input/output loop