fixed "Cannot read property 'length' of undefined" when creating and opening new file