How can I add a method to the `string` table and modify self inside it ?

Basically, I'm trying to mimic the behaviour of the `io.StringIO.read` method in python, which reads `n` char in the string and returns them, modifying the string by "consuming" it.

I tried this:

```lua
function string.read(str, n)
  to_return = str:sub(1, n)
  str = str:sub(n + 1)
  return to_return
end

local foo = "heyfoobarhello"
print(string.read(foo, 3))
print(foo)

```

Output is:

```
hey
heyfoobarhello

```

I expected the second line to be only `foobarhello`.

How can I achieve this ?