added error detection

Added error detection for input strings as well as keeping line # and
reporting it in error messages.