diff --git a/CHANGELOG.md b/CHANGELOG.md
index f7307f7..bd4a517 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 
 ### Fixed
 
+- The output was corrupted when a callback function tried to update a
+  line that was no longer visible on the screen.
+
 - When a table did not include a summary, "incremental" and "final"
   mode added "None" as the last row.
 
diff --git a/pyout/interface.py b/pyout/interface.py
index d40097c..71d8687 100644
--- a/pyout/interface.py
+++ b/pyout/interface.py
@@ -30,6 +30,9 @@ class Stream(object):
     def width(self):
         """Maximum line width.
         """
+    @abc.abstractproperty
+    def height(self):
+        """Maximum number of rows that are visible."""
 
     @abc.abstractmethod
     def write(self, text):
@@ -190,12 +193,34 @@ class Writer(object):
             # possible for the summary lines to shrink.
             lgr.debug("Clearing summary")
             self._stream.clear_last_lines(last_summary_len)
+        else:
+            last_summary_len = 0
+
         content, status, summary = self._content.update(row, style)
+
+        single_row_updated = False
         if isinstance(status, int):
-            lgr.debug("Overwriting line %d with %r", status, row)
-            self._stream.overwrite_line(self._last_content_len - status,
-                                        content)
-        else:
+            height = self._stream.height
+            if height is None:  # non-tty
+                n_visible = self._last_content_len
+            else:
+                n_visible = min(
+                    height - last_summary_len - 1,  # -1 for current line.
+                    self._last_content_len)
+
+            n_back = self._last_content_len - status
+            if n_back > n_visible:
+                lgr.debug("Cannot move back %d rows for update; "
+                          "only %d visible rows",
+                          n_back, n_visible)
+                status = "repaint"
+                content = six.text_type(self._content)
+            else:
+                lgr.debug("Overwriting line %d with %r", status, row)
+                self._stream.overwrite_line(n_back, content)
+                single_row_updated = True
+
+        if not single_row_updated:
             if status == "repaint":
                 lgr.debug("Repainting the whole thing.  Blame row %r", row)
                 self._stream.move_to(self._last_content_len)
diff --git a/pyout/tabular.py b/pyout/tabular.py
index f5068f2..52cf315 100644
--- a/pyout/tabular.py
+++ b/pyout/tabular.py
@@ -24,6 +24,7 @@ class TerminalStream(interface.Stream):
 
     def __init__(self):
         self.term = Terminal()
+        self._height = self.term.height
 
     @property
     def width(self):
@@ -31,6 +32,12 @@ class TerminalStream(interface.Stream):
         """
         return self.term.width
 
+    @property
+    def height(self):
+        """Terminal height.
+        """
+        return self._height
+
     def write(self, text):
         """Write `text` to terminal.
         """

diff --git a/pyout/tests/test_tabular.py b/pyout/tests/test_tabular.py
index 8a4d172..8664f0f 100644
--- a/pyout/tests/test_tabular.py
+++ b/pyout/tests/test_tabular.py
@@ -37,14 +37,36 @@ class Terminal(blessings.Terminal):
     def width(self):
         return 100
 
+    @property
+    def height(self):
+        return 20
+
+
+class TerminalNonInteractive(Terminal):
+
+    @property
+    def width(self):
+        return None
+
+    @property
+    def height(self):
+        return None
+
 
 class Tabular(TheRealTabular):
     """Test-specific subclass of pyout.Tabular.
     """
 
     def __init__(self, *args, **kwargs):
-        with patch("pyout.interface.sys.stdout.isatty", return_value=True):
-            with patch("pyout.tabular.Terminal", Terminal):
+        interactive = kwargs.pop("interactive", True)
+        if interactive:
+            term = Terminal
+        else:
+            term = TerminalNonInteractive
+
+        with patch("pyout.interface.sys.stdout.isatty",
+                   return_value=interactive):
+            with patch("pyout.tabular.Terminal", term):
                 super(Tabular, self).__init__(*args, **kwargs)
 
     @property
@@ -894,6 +916,53 @@ def test_tabular_write_callable_values_multi_return():
     assert_contains_nc(lines, "foo done /tmp/a")
 
 
+@pytest.mark.timeout(10)
+@pytest.mark.parametrize("nrows", [20, 21])
+@pytest.mark.parametrize("interactive", [True, False])
+def test_tabular_callback_to_hidden_row(nrows, interactive):
+    if sys.version_info < (3,):
+        try:
+            import jsonschema
+        except ImportError:
+            pass
+        else:
+            # Ideally we'd also check if the tests are running under
+            # coverage, but I don't know a way to do that.
+            pytest.xfail(
+                "Hangs for unknown reason in py2/coverage/jsonschema run")
+
+    delay = Delayed("OK")
+    out = Tabular(interactive=interactive,
+                  style={"status": {"aggregate": len}})
+    # Make sure we're in update mode even for interactive=False.
+    out.mode = "update"
+    with out:
+        for i in range(1, nrows + 1):
+            status = delay.run if i == 3 else "s{:02d}".format(i)
+            out(OrderedDict([("name", "foo{:02d}".format(i)),
+                             ("status", status)]))
+        delay.now = True
+
+    lines = out.stdout.splitlines()
+    # The test terminal height is 20.  The summary line takes up one
+    # line and the current line takes up another, so we have 18
+    # available rows. Row 3 goes off the screen when we have 21 rows.
+
+    if nrows > 20 and interactive:
+        # No leading escape codes because it was part of a whole repaint.
+        nexpected_plain = 1
+        nexpected_updated = 0
+    else:
+        nexpected_plain = 0
+        nexpected_updated = 1
+
+    assert len([l for l in lines if l == "foo03 OK "]) == nexpected_plain
+
+    cuu1 = unicode_cap("cuu1")
+    updated = [l for l in lines if l.startswith(cuu1) and "foo03 OK " in l]
+    assert len(updated) == nexpected_updated
+
+
 @pytest.mark.timeout(10)
 @pytest.mark.parametrize("result",
                          [{"status": "done", "path": "/tmp/a"},

breeding emtpy lines while listing output which leaves the screen
just do smth like
```
datalad install ///openfmri
datalad install openfmri/ds000{011,11*}
datalad ls -rLa openfmri 
```

- there is a bunch of empty lines at the end of the listing before "EXITED" reported by datalad exiting the loop.  Feels like a counter of some kind is incorrect while accounting for stuff which left the screen already
- if you scroll terminal up - you will see some full terminal height empty spaces with one line of the listing at the bottom.  Ideally I expect that output either be completely redrawn (thus repeating previously output lines) or just continuing listing with possibly adjusted formatting (e.g. the widths of the fields).
- when I have used it on my local `openfmri` superdataset installation then there were also smaller periods of emptiness if you scroll terminal up
pyout/tests/test_tabular.py::test_tabular_callback_to_hidden_row[True-21]
pyout/tests/test_tabular.py::test_tabular_write_color pyout/tests/test_tabular.py::test_tabular_write_empty_string pyout/tests/test_tabular.py::test_tabular_write_missing_column pyout/tests/test_tabular.py::test_tabular_write_missing_column_missing_text pyout/tests/test_tabular.py::test_tabular_write_list_value pyout/tests/test_tabular.py::test_tabular_write_missing_column_missing_object_data pyout/tests/test_tabular.py::test_tabular_write_columns_from_orderdict_row pyout/tests/test_tabular.py::test_tabular_write_columns_orderdict_mapping[sequence] pyout/tests/test_tabular.py::test_tabular_write_columns_orderdict_mapping[dict] pyout/tests/test_tabular.py::test_tabular_write_data_as_list pyout/tests/test_tabular.py::test_tabular_write_header pyout/tests/test_tabular.py::test_tabular_write_data_as_object pyout/tests/test_tabular.py::test_tabular_write_different_data_types_same_output pyout/tests/test_tabular.py::test_tabular_write_header_with_style pyout/tests/test_tabular.py::test_tabular_nondefault_separator pyout/tests/test_tabular.py::test_tabular_write_data_as_list_no_columns pyout/tests/test_tabular.py::test_tabular_write_style_override pyout/tests/test_tabular.py::test_tabular_default_style pyout/tests/test_tabular.py::test_tabular_write_multicolor pyout/tests/test_tabular.py::test_tabular_write_empty_string_nostyle pyout/tests/test_tabular.py::test_tabular_write_style_flanking pyout/tests/test_tabular.py::test_tabular_write_align pyout/tests/test_tabular.py::test_tabular_rewrite pyout/tests/test_tabular.py::test_tabular_rewrite_with_header pyout/tests/test_tabular.py::test_tabular_rewrite_multi_id pyout/tests/test_tabular.py::test_tabular_rewrite_multi_value pyout/tests/test_tabular.py::test_tabular_rewrite_auto_width pyout/tests/test_tabular.py::test_tabular_non_hashable_id_error pyout/tests/test_tabular.py::test_tabular_write_lookup_color pyout/tests/test_tabular.py::test_tabular_write_lookup_bold pyout/tests/test_tabular.py::test_tabular_write_lookup_bold_false pyout/tests/test_tabular.py::test_tabular_write_lookup_non_hashable pyout/tests/test_tabular.py::test_tabular_write_intervals_color pyout/tests/test_tabular.py::test_tabular_write_intervals_color_open_ended pyout/tests/test_tabular.py::test_tabular_write_intervals_color_outside_intervals pyout/tests/test_tabular.py::test_tabular_write_intervals_bold pyout/tests/test_tabular.py::test_tabular_write_intervals_missing pyout/tests/test_tabular.py::test_tabular_write_transform pyout/tests/test_tabular.py::test_tabular_write_transform_with_header pyout/tests/test_tabular.py::test_tabular_write_transform_autowidth pyout/tests/test_tabular.py::test_tabular_write_transform_on_header pyout/tests/test_tabular.py::test_tabular_write_transform_func_error pyout/tests/test_tabular.py::test_tabular_write_width_truncate_long pyout/tests/test_tabular.py::test_tabular_write_autowidth pyout/tests/test_tabular.py::test_tabular_write_autowidth_with_header pyout/tests/test_tabular.py::test_tabular_write_autowidth_min pyout/tests/test_tabular.py::test_tabular_write_autowidth_min_max[marker=True] pyout/tests/test_tabular.py::test_tabular_write_autowidth_min_max[marker=False] pyout/tests/test_tabular.py::test_tabular_write_autowidth_min_max[marker=\u2026] pyout/tests/test_tabular.py::test_tabular_write_autowidth_min_max_with_header pyout/tests/test_tabular.py::test_tabular_write_autowidth_different_data_types_same_output pyout/tests/test_tabular.py::test_tabular_write_autowidth_auto_false_exception pyout/tests/test_tabular.py::test_tabular_fixed_width_exceeds_total pyout/tests/test_tabular.py::test_tabular_auto_width_exceeds_total pyout/tests/test_tabular.py::test_tabular_auto_width_exceeds_total_multiline pyout/tests/test_tabular.py::test_tabular_write_callable_values pyout/tests/test_tabular.py::test_tabular_write_callable_transform_nothing pyout/tests/test_tabular.py::test_tabular_write_callable_values_multi_return pyout/tests/test_tabular.py::test_tabular_callback_to_hidden_row[True-20] pyout/tests/test_tabular.py::test_tabular_callback_to_hidden_row[False-20] pyout/tests/test_tabular.py::test_tabular_callback_to_hidden_row[False-21] pyout/tests/test_tabular.py::test_tabular_write_callable_values_multicol_key_infer_column[result=tuple] pyout/tests/test_tabular.py::test_tabular_write_callable_values_multicol_key_infer_column[result=dict] pyout/tests/test_tabular.py::test_tabular_write_generator_function_values[gen_func] pyout/tests/test_tabular.py::test_tabular_write_generator_function_values[generator] pyout/tests/test_tabular.py::test_tabular_write_generator_values_multireturn pyout/tests/test_tabular.py::test_tabular_write_wait_noop_if_nothreads pyout/tests/test_tabular.py::test_tabular_write_delayed[dict] pyout/tests/test_tabular.py::test_tabular_write_delayed[list] pyout/tests/test_tabular.py::test_tabular_write_delayed[attrs] pyout/tests/test_tabular.py::test_tabular_summary pyout/tests/test_tabular.py::test_tabular_shrinking_summary pyout/tests/test_tabular.py::test_tabular_mode_invalid pyout/tests/test_tabular.py::test_tabular_mode_default pyout/tests/test_tabular.py::test_tabular_mode_after_write pyout/tests/test_tabular.py::test_tabular_mode_incremental pyout/tests/test_tabular.py::test_tabular_mode_final pyout/tests/test_tabular.py::test_tabular_mode_final_summary