Deliberately I\'m having this method which writes into a file, so I tried to handle the exception of the possiblity that I\'m writing into a closed file:
Exception of the type ios_base::failure, However note that you should have set the appropriate flag with ios::exceptions to generate the exceptions or else only internal state flags will be set for indicating the error, which is the default behavior for streams.