Prevent exception on empty script

Fixes #545