Fix error in open_with_retry function