Added input and output file checking.