context: better error messages + fix race on file.Close