Fix leakage

Improves error handling (come on, e.printStackTrace? :]) + closes files 

(as it behaves REALLY BAD on windows)