lib/file: protect from double close

Signed-off-by: Jean Privat <jean@pryen.org>