Completed version of stage one with working ctrl d to exit