undefined lines throwing errors

I was having trouble where the terminal was reporting a different line count then what actually existed. As a result, a exception was being thrown. This makes sure the line exists before trying to operate on it.