OMG, can't remember how hard safe resource handling in Java is. I'm thinking of discarding this PR, the program is terminated afterwards anyway...