Move lastLine setter into conditional block to prevent .commands and blank lines from setting lastLine