I can \"fix\" the below exception with a try-catch loop but I cannot understand the reason.
It is thrown if an exceptional situation occurs with the I/O, for example the source of the stream is no longer available.
In such cases your program should be able to recover. Either by re-reading the source, or by using some defaults, or by alerting the user about the problem.
You are forced to catch
it, because it is a checked exception, and you are supposed to be able to recover from those.
Of course, you have the option to declare that the current menthod throws
this exception to caller methods, but you will have to catch it eventually (or let it bubble up to the main method, when it is simply printed on the console and the program execution stops)