closing reader and buffer on exception