update deps
ensure file is closed on error