end() can also return false. Check this first