Added more input checking for lines