added error catch

error catching for input output