Fairly recently we made a sneaky change to the read and write functions to allow single elements to be passed, since it's a common 'papercut' issue for new users and our training department. The preferred syntax is still to call it with a list, but single values are accepted - that explains the syntax in the OP working.
Basically correct - gateway event scripts are the only system that still uses 'legacy' scripting, and therefore needs you to reimport system
inside any defined functions.