pass a fileobj instead of str