Fixes built-in function errors

Also adds new read, write functions.