diff --git a/configure.ac b/configure.ac
index ffcfd49..c564848 100644
--- a/configure.ac
+++ b/configure.ac
@@ -208,7 +208,7 @@ AC_CHECK_FUNCS([ceil floor round])
 
 # Search for the required modules.
 
-VTE_PKGS="glib-2.0 >= $GLIB_REQUIRED gobject-2.0 pango >= $PANGO_REQUIRED gtk+-$GTK_API_VERSION >= $GTK_REQUIRED gobject-2.0 gio-2.0 gio-unix-2.0 gnutls >= 3.2.0"
+VTE_PKGS="glib-2.0 >= $GLIB_REQUIRED gobject-2.0 pango >= $PANGO_REQUIRED gtk+-$GTK_API_VERSION >= $GTK_REQUIRED gobject-2.0 gio-2.0 gio-unix-2.0 gnutls >= 3.2.0 zlib"
 PKG_CHECK_MODULES([VTE],[$VTE_PKGS])
 AC_SUBST([VTE_PKGS])
 
diff --git a/src/vtestream-file.h b/src/vtestream-file.h
index 729b46c..fd698f9 100644
--- a/src/vtestream-file.h
+++ b/src/vtestream-file.h
@@ -28,29 +28,32 @@
  *   to physical file offsets, storing the stream in at most 3 continuous
  *   regions of the file. See below for details how this mapping is done.
  *
- *   It operates with a fixed block size (4096 bytes at the moment), allows
+ *   It operates with a fixed block size (64kB at the moment), allows
  *   random-access-read of a single block, random-access-overwrite of a single
  *   block within the stream, write (append) a single block right after the
  *   current head, advancing the tail by arbitrary number of blocks, and
- *   resetting.
+ *   resetting. The appended block can be shorter, in that case we still
+ *   advance by 64kB and let the operating system leave a gap (sparse blocks)
+ *   in the file which is crucial for compression.
  *
  *   (Random-access-overwrite within the existing area is a very rare event,
- *   occurs only when the terminal window is made taller by the user. We use
- *   it to redo differently the latest appends. In the topmost layer it's
- *   achieved by truncating at the head of the stream, and then appending
- *   again. In this layer and also in the next one, offering
- *   random-access-overwrite instead of truncation makes the implementation a
- *   lot easier. This approach also guarantees that in the rare case when we
- *   need to reuse the IV, the same previous file system block using that same
- *   IV will be overwritten.)
+ *   occurs only when the terminal window size changes. We use it to redo
+ *   differently the latest appends. In the topmost layer it's achieved by
+ *   truncating at the head of the stream, and then appending again. In this
+ *   layer and also in the next one, offering random-access-overwrite instead
+ *   of truncation makes the implementation a lot easier. This approach also
+ *   guarantees (FIXME: does it really?) that in the rare case when we need to
+ *   reuse the IV, the same previous file system block using that same IV will
+ *   be overwritten.)
  *
  *   The name was chosen because VteFileStream's way of advancing the head and
  *   the tail is kinda like a snake, and the mapping to file offsets reminds
  *   me of the well-known game on old mobile phones.
  *
- * o The middle layer is called VteBoa. It does encryption and integrity
- *   check. It has the same API as the snake, except that the blocksize is a
- *   bit smaller (4080 bytes) to leave room for the integrity data.
+ * o The middle layer is called VteBoa. It does compression and encryption
+ *   along with integrity check. It has (almost) the same API as the snake,
+ *   but that the blocksize is a bit smaller to leave room for the required
+ *   overhead.
  *
  *   The name was chosen because the world of encryption is full of three
  *   letter abbreviations. At this moment we use GNU TLS's method for doing
@@ -70,9 +73,11 @@
  */
 
 #include <errno.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <zlib.h>
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
 
@@ -85,15 +90,19 @@
 #define VTE_CIPHER_TAG_SIZE   16
 
 #ifndef VTESTREAM_MAIN
-#define VTE_SNAKE_BLOCKSIZE 4096
-#define VTE_BOA_BLOCKSIZE   (VTE_SNAKE_BLOCKSIZE - VTE_CIPHER_TAG_SIZE)
+#define VTE_SNAKE_BLOCKSIZE    65536
+/* Subtract encryption overhead, round down to a multiple of encryption blocksize, subtract compression overhead */
+#define VTE_BOA_BLOCKSIZE      ((VTE_SNAKE_BLOCKSIZE - 4 - VTE_CIPHER_TAG_SIZE) / VTE_CIPHER_BLOCK_SIZE * VTE_CIPHER_BLOCK_SIZE - 4)
 #else
-#define VTE_SNAKE_BLOCKSIZE 4  /* Small block size for unit testing */
-#define VTE_BOA_BLOCKSIZE   3
+#define VTE_SNAKE_BLOCKSIZE    4  /* Small block size for unit testing */
+#define VTE_BOA_BLOCKSIZE      3
 #endif
 
+#define ALIGN_FLOOR(x, y) ((x) / (y) * (y))
+#define ALIGN_CEIL(x, y) (((x) + (y) - 1) / (y) * (y))
+
 #define OFFSET_BOA_TO_SNAKE(x) ((x) / VTE_BOA_BLOCKSIZE * VTE_SNAKE_BLOCKSIZE)
-#define ALIGN_BOA(x) ((x) / VTE_BOA_BLOCKSIZE * VTE_BOA_BLOCKSIZE)
+#define ALIGN_BOA(x) ALIGN_FLOOR((x), VTE_BOA_BLOCKSIZE)
 #define MOD_BOA(x)   ((x) % VTE_BOA_BLOCKSIZE)
 
 
@@ -150,6 +159,35 @@ _file_reset (int fd)
         _file_try_truncate (fd, 0);
 }
 
+static gboolean
+_file_try_punch_hole (int fd, gsize offset, gsize len)
+{
+#ifndef VTESTREAM_MAIN
+#ifdef FALLOC_FL_PUNCH_HOLE
+        int ret;
+
+        if (G_UNLIKELY (fd == -1))
+                return FALSE;
+
+        do {
+                ret = fallocate (fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, len);
+        } while (ret == -1 && errno == EINTR);
+
+        return !ret;
+#else
+        return FALSE;
+#endif
+#else /* VTESTREAM_MAIN */
+        /* For unittesting, overwrite the part with underscores. */
+        char c = '_';
+        while (len--) {
+                if (pwrite(fd, &c, 1, offset++) != 1)
+                        return FALSE;
+        }
+        return TRUE;
+#endif
+}
+
 static gsize
 _file_read (int fd, char *data, gsize len, gsize offset)
 {
@@ -284,7 +322,7 @@ typedef struct _VteSnakeClass {
         GObjectClass parent_class;
 
         void (*reset) (VteSnake *snake, gsize offset);
-        void (*write) (VteSnake *snake, gsize offset, const char *data);
+        void (*write) (VteSnake *snake, gsize offset, const char *data, gsize len);
         gboolean (*read) (VteSnake *snake, gsize offset, char *data);
         void (*advance_tail) (VteSnake *snake, gsize offset);
         gsize (*tail) (VteSnake *snake);
@@ -364,12 +402,12 @@ _vte_snake_offset_map (VteSnake *snake, gsize offset)
 
 /*
  * offset is either within the stream (overwrite data), or at its head (append data).
- * data is VTE_SNAKE_BLOCKSIZE bytes large.
+ * data is at most VTE_SNAKE_BLOCKSIZE bytes large; if shorter then the remaining amount is skipped.
  * When appending, the following state transfers can occur:
  * 1->2, 2->3.
  */
 static void
-_vte_snake_write (VteSnake *snake, gsize offset, const char *data)
+_vte_snake_write (VteSnake *snake, gsize offset, const char *data, gsize len)
 {
         gsize fd_offset;
 
@@ -402,12 +440,17 @@ _vte_snake_write (VteSnake *snake, gsize offset, const char *data)
                         snake->segment[last_segment].st_head += VTE_SNAKE_BLOCKSIZE;
                         snake->segment[last_segment].fd_head += VTE_SNAKE_BLOCKSIZE;
                 }
+                if (snake->state != 2) {
+                        /* Grow the file with sparse blocks to make sure that later pread() can
+                         * read back a whole block, even if we are about to write a shorter one. */
+                        _file_try_truncate (snake->fd, fd_offset + VTE_SNAKE_BLOCKSIZE);
+                }
                 snake->head = offset + VTE_SNAKE_BLOCKSIZE;
         } else {
                 /* Overwriting an existing block. */
                 fd_offset = _vte_snake_offset_map(snake, offset);
         }
-        _file_write (snake->fd, data, VTE_SNAKE_BLOCKSIZE, fd_offset);
+        _file_write (snake->fd, data, len, fd_offset);
 }
 
 /* Place VTE_SNAKE_BLOCKSIZE bytes at data */
@@ -446,6 +489,7 @@ _vte_snake_advance_tail (VteSnake *snake, gsize offset)
         while (offset > snake->segment[0].st_tail) {
                 if (offset < snake->segment[0].st_head) {
                         /* Drop some (but not all) bytes from the first segment. */
+                        _file_try_punch_hole (snake->fd, snake->segment[0].fd_tail, offset - snake->tail);
                         snake->segment[0].fd_tail += offset - snake->tail;
                         snake->segment[0].st_tail = snake->tail = offset;
                         return;
@@ -461,11 +505,13 @@ _vte_snake_advance_tail (VteSnake *snake, gsize offset)
                                 snake->state = 1;
                                 break;
                         case 3:
+                                _file_try_punch_hole (snake->fd, snake->segment[0].fd_tail, snake->segment[0].fd_head - snake->segment[0].fd_tail);
                                 snake->segment[0] = snake->segment[1];
                                 snake->segment[1] = snake->segment[2];
                                 snake->state = 4;
                                 break;
                         case 4:
+                                _file_try_punch_hole (snake->fd, snake->segment[0].fd_tail, snake->segment[0].fd_head - snake->segment[0].fd_tail);
                                 snake->segment[0] = snake->segment[1];
                                 snake->state = 1;
                                 break;
@@ -509,7 +555,7 @@ _vte_snake_class_init (VteSnakeClass *klass)
 /******************************************************************************************/
 
 /*
- * VteBoa: Encrypt an elephant to make it look like a hat.
+ * VteBoa: Compress and encrypt an elephant to make it look like a hat.
  *
  *                 _.----._
  *                /         \._______
@@ -519,6 +565,32 @@ _vte_snake_class_init (VteSnakeClass *klass)
  *             /                          \
  *   ________/                             \_________________
  *  '------------------------------------------------------'-'
+ *
+ * A boa block is converted to a snake block as follows:
+ *
+ *              snake block
+ * ├────────────────────────────────────┤
+ *
+ *   enc                            enc
+ * 0 len 4     encrypted data     E tag T
+ * └─────┼─────┬────────────┬─────┼─────┘
+ *       4 com 8 compressed C pad E
+ *         len      data
+ *
+ * ┌ ─ ─ ─ ─ ─ ┘            └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
+ *
+ * ├────────────────────────────────────────────────────────┤
+ *                          boa block
+ *
+ * Encryption layer:
+ * - 0..4: The value of T-4 (4 bytes)
+ * - 4..E: The encrypted data (length is multiple of VTE_CIPHER_BLOCK_SIZE)
+ * - E..T: Encryption verification tag (VTE_CIPHER_TAG_SIZE bytes)
+ *
+ * Compression layer:
+ * - 4..8: The value of C-8 (4 bytes)
+ * - 8..C: The compressed (or uncompressed if uncompressable) data
+ * - C..E: Padding to make E-4 a multiple of VTE_CIPHER_BLOCK_SIZE
  */
 
 typedef struct _VteBoa {
@@ -537,6 +609,7 @@ typedef struct _VteBoa {
                 unsigned char padding[VTE_CIPHER_IV_SIZE];
         } iv;
         char *buf;
+        uLong compressBound;
 } VteBoa;
 
 typedef struct _VteBoaClass {
@@ -562,7 +635,8 @@ _vte_boa_init (VteBoa *boa)
         unsigned char key[VTE_CIPHER_KEY_SIZE];
         gnutls_datum_t datum_key;
 
-        boa->buf = g_malloc(VTE_SNAKE_BLOCKSIZE);
+        boa->compressBound = compressBound(VTE_BOA_BLOCKSIZE);
+        boa->buf = g_malloc(MAX(VTE_SNAKE_BLOCKSIZE, 8 + boa->compressBound));
 
         gnutls_global_init ();
 
@@ -626,24 +700,45 @@ _vte_boa_reset (VteBoa *boa, gsize offset)
 static void
 _vte_boa_write (VteBoa *boa, gsize offset, const char *data)
 {
+        uLongf destLen = boa->compressBound;
+        uLongf destLen2;
+
         g_assert_cmpuint (offset, >=, boa->tail);
         g_assert_cmpuint (offset, <=, boa->head);
         g_assert_cmpuint (offset % VTE_BOA_BLOCKSIZE, ==, 0);
 
 #ifndef VTESTREAM_MAIN
+        g_assert (compress2 ((Bytef *) (boa->buf + 8), &destLen, (Bytef *) data, VTE_BOA_BLOCKSIZE, 1) == Z_OK);
+        if (G_UNLIKELY (destLen >= VTE_BOA_BLOCKSIZE)) {  // TODO go for the other branch if could hardly compress and would take the same amount of boa blocks.
+                /* Could not compress, store the original. */
+                memcpy (boa->buf + 8, data, VTE_BOA_BLOCKSIZE);
+                destLen = VTE_BOA_BLOCKSIZE;
+        }
+        *((guint32 *) (boa->buf + 4)) = (guint32) destLen;
+        destLen += 4;
+
+        /* Add padding to make it a multiple of VTE_CIPHER_BLOCK_SIZE */
+        destLen2 = ALIGN_CEIL(destLen, VTE_CIPHER_BLOCK_SIZE);
+        memset(boa->buf + 4 + destLen2, 0, destLen2 - destLen);
+        destLen = destLen2;
+
         boa->iv.offset = offset;
         gnutls_cipher_set_iv (boa->cipher_hd, &boa->iv, VTE_CIPHER_IV_SIZE);
-        gnutls_cipher_encrypt2 (boa->cipher_hd, data, VTE_BOA_BLOCKSIZE, boa->buf, VTE_BOA_BLOCKSIZE);
-        gnutls_cipher_tag (boa->cipher_hd, boa->buf + VTE_BOA_BLOCKSIZE, VTE_CIPHER_TAG_SIZE);
+        gnutls_cipher_encrypt (boa->cipher_hd, boa->buf + 4, destLen);
+        gnutls_cipher_tag (boa->cipher_hd, boa->buf + 4 + destLen, VTE_CIPHER_TAG_SIZE);
+        destLen += VTE_CIPHER_TAG_SIZE;
+        *((guint32 *) boa->buf) = (guint32) destLen;
+        destLen += 4;
 #else
         /* Fake encryption (lowercase<->uppercase) and fake integrity data ('#') for unit testing */
         boa->buf[0] = data[0] ^ 0x20;
         boa->buf[1] = data[1] ^ 0x20;
         boa->buf[2] = data[2] ^ 0x20;
         boa->buf[3] = '#';
+        destLen = 4;
+        (void) destLen2;  /* silence gcc */
 #endif
-
-        _vte_snake_write (&boa->parent, OFFSET_BOA_TO_SNAKE(offset), boa->buf);
+        _vte_snake_write (&boa->parent, OFFSET_BOA_TO_SNAKE(offset), boa->buf, destLen);
 
         if (G_LIKELY (offset == boa->head)) {
                 boa->head += VTE_BOA_BLOCKSIZE;
@@ -654,7 +749,9 @@ _vte_boa_write (VteBoa *boa, gsize offset, const char *data)
 static gboolean
 _vte_boa_read (VteBoa *boa, gsize offset, char *data)
 {
+        uLongf destLen = VTE_BOA_BLOCKSIZE;
         unsigned char tag[VTE_CIPHER_TAG_SIZE];
+        guint32 sourceLen;
         guint8 faulty = 0;
         unsigned int i, j;
 
@@ -664,13 +761,17 @@ _vte_boa_read (VteBoa *boa, gsize offset, char *data)
                 return FALSE;
 
 #ifndef VTESTREAM_MAIN
+        sourceLen = *((guint32 *) boa->buf);
+        g_assert (sourceLen >= VTE_CIPHER_TAG_SIZE);
+        sourceLen -= VTE_CIPHER_TAG_SIZE;
+
         boa->iv.offset = offset;
         gnutls_cipher_set_iv (boa->cipher_hd, &boa->iv, VTE_CIPHER_IV_SIZE);
-        gnutls_cipher_decrypt2 (boa->cipher_hd, boa->buf, VTE_BOA_BLOCKSIZE, data, VTE_BOA_BLOCKSIZE);
+        gnutls_cipher_decrypt (boa->cipher_hd, boa->buf + 4, sourceLen);
         gnutls_cipher_tag (boa->cipher_hd, tag, VTE_CIPHER_TAG_SIZE);
 
         /* Constant time comparison: 738601#c66 */
-        for (i = 0, j = VTE_BOA_BLOCKSIZE; i < VTE_CIPHER_TAG_SIZE; i++, j++) {
+        for (i = 0, j = 4 + sourceLen; i < VTE_CIPHER_TAG_SIZE; i++, j++) {
                 faulty |= tag[i] ^ boa->buf[j];
         }
         if (faulty) {
@@ -679,19 +780,25 @@ _vte_boa_read (VteBoa *boa, gsize offset, char *data)
                  * One possible reason is a previous disk full, leaving a hole in the file.
                  * To make it more complicated, we're not sure that we're using the actual filesystem
                  * block size, so a simple check for a fully zero block wouldn't suffice.
-                 * As of now, just return a normal failure, wiping out the data to be absolutely sure
-                 * that the caller won't use it.
+                 * As of now, just return a normal failure.
                  */
-                memset(data, 0, VTE_BOA_BLOCKSIZE);
                 return FALSE;
         }
+
+        sourceLen = *((guint32 *) (boa->buf + 4));
+        if (G_LIKELY (sourceLen < VTE_BOA_BLOCKSIZE)) {
+                g_assert (uncompress ((Bytef *) data, &destLen, (Bytef *) (boa->buf + 8), sourceLen) == Z_OK);
+                g_assert (destLen == VTE_BOA_BLOCKSIZE);
+        } else {
+                memcpy (data, boa->buf + 8, VTE_BOA_BLOCKSIZE);
+        }
 #else
         /* Fake decryption (lowercase<->uppercase) and fake integrity verification ('#') for unit testing */
         data[0] = boa->buf[0] ^ 0x20;
         data[1] = boa->buf[1] ^ 0x20;
         data[2] = boa->buf[2] ^ 0x20;
         g_assert_cmpuint(boa->buf[3], ==, '#');
-        (void) tag; (void) faulty; (void) i; (void) j;  /* silence gcc */
+        (void) tag; (void) faulty; (void) i; (void) j; (void) destLen; (void) sourceLen;  /* silence gcc */
 #endif
         return TRUE;
 }
@@ -1010,28 +1117,30 @@ _vte_file_stream_class_init (VteFileStreamClass *klass)
         g_assert (memcmp(__buf, __contents, __head - __tail) == 0); \
 } while (0)
 
+#define snake_write(snake, offset, str) _vte_snake_write((snake), (offset), (str), strlen(str))
+
 static void
 test_snake (void)
 {
         VteSnake *snake = g_object_new (VTE_TYPE_SNAKE, NULL);
 
         /* Test overwriting data */
-        _vte_snake_write (snake, 0, "aaaa");
+        snake_write (snake, 0, "aaaa");
         assert_snake (snake, 1, 0, 4, "aaaa");
 
-        _vte_snake_write (snake, 4, "bbbb");
+        snake_write (snake, 4, "bbbb");
         assert_file (snake->fd, "aaaabbbb");
         assert_snake (snake, 1, 0, 8, "aaaabbbb");
 
-        _vte_snake_write (snake, 4, "cccc");
+        snake_write (snake, 4, "cccc");
         assert_file (snake->fd, "aaaacccc");
         assert_snake (snake, 1, 0, 8, "aaaacccc");
 
-        _vte_snake_write (snake, 0, "dddd");
+        snake_write (snake, 0, "dddd");
         assert_file (snake->fd, "ddddcccc");
         assert_snake (snake, 1, 0, 8, "ddddcccc");
 
-        _vte_snake_write (snake, 8, "eeee");
+        snake_write (snake, 8, "eeee");
         assert_file (snake->fd, "ddddcccceeee");
         assert_snake (snake, 1, 0, 12, "ddddcccceeee");
 
@@ -1040,51 +1149,51 @@ test_snake (void)
         assert_snake (snake, 1, 0, 0, "");
 
         /* State 1 */
-        _vte_snake_write (snake, 0, "aaaa");
-        _vte_snake_write (snake, 4, "bbbb");
+        snake_write (snake, 0, "aaaa");
+        snake_write (snake, 4, "bbbb");
         assert_file_starts_with (snake->fd, "aaaabbbb");
         assert_snake (snake, 1, 0, 8, "aaaabbbb");
 
         /* Stay in state 1 */
         _vte_snake_advance_tail (snake, 4);
-        _vte_snake_write (snake, 8, "cccc");
-        assert_file (snake->fd, "aaaabbbbcccc");
+        snake_write (snake, 8, "cccc");
+        assert_file (snake->fd, "____bbbbcccc");
         assert_snake (snake, 1, 4, 12, "bbbbcccc");
 
         /* State 1 -> 2 */
         _vte_snake_advance_tail (snake, 8);
-        _vte_snake_write (snake, 12, "dddd");
-        assert_file (snake->fd, "ddddbbbbcccc");
+        snake_write (snake, 12, "dddd");
+        assert_file (snake->fd, "dddd____cccc");
         assert_snake (snake, 2, 8, 16, "ccccdddd");
 
         /* Stay in state 2 */
-        _vte_snake_write (snake, 16, "eeee");
+        snake_write (snake, 16, "eeee");
         assert_file (snake->fd, "ddddeeeecccc");
         assert_snake (snake, 2, 8, 20, "ccccddddeeee");
 
         /* State 2 -> 3 */
-        _vte_snake_write (snake, 20, "ffff");
+        snake_write (snake, 20, "ffff");
         assert_file (snake->fd, "ddddeeeeccccffff");
         assert_snake (snake, 3, 8, 24, "ccccddddeeeeffff");
 
         /* State 3 -> 4 */
         _vte_snake_advance_tail (snake, 12);
-        assert_file (snake->fd, "ddddeeeeccccffff");
+        assert_file (snake->fd, "ddddeeee____ffff");
         assert_snake (snake, 4, 12, 24, "ddddeeeeffff");
 
         /* Stay in state 4 */
         _vte_snake_advance_tail (snake, 16);
-        assert_file (snake->fd, "ddddeeeeccccffff");
+        assert_file (snake->fd, "____eeee____ffff");
         assert_snake (snake, 4, 16, 24, "eeeeffff");
 
         /* State 4 -> 1 */
         _vte_snake_advance_tail (snake, 20);
-        assert_file (snake->fd, "ddddeeeeccccffff");
+        assert_file (snake->fd, "____________ffff");
         assert_snake (snake, 1, 20, 24, "ffff");
 
         /* State 1 -> 2 */
-        _vte_snake_write (snake, 24, "gggg");
-        assert_file (snake->fd, "ggggeeeeccccffff");
+        snake_write (snake, 24, "gggg");
+        assert_file (snake->fd, "gggg________ffff");
         assert_snake (snake, 2, 20, 28, "ffffgggg");
 
         /* Reset */
@@ -1092,7 +1201,7 @@ test_snake (void)
         assert_snake (snake, 1, 100, 100, "");
 
         /* Stay in state 1 */
-        _vte_snake_write (snake, 100, "zzzz");
+        snake_write (snake, 100, "zzzz");
         assert_file_starts_with (snake->fd, "zzzz");
         assert_snake (snake, 1, 100, 104, "zzzz");
 
@@ -1120,7 +1229,7 @@ test_boa (void)
         /* State 1 -> 2 */
         _vte_boa_advance_tail (boa, 6);
         _vte_boa_write (boa, 9, "ddd");
-        assert_file (snake->fd, "DDD#BBB#CCC#");
+        assert_file (snake->fd, "DDD#____CCC#");
         assert_snake (snake, 2, 8, 16, "CCC#DDD#");
         assert_boa (boa, 6, 12, "cccddd");
 
@@ -1215,13 +1324,13 @@ test_stream (void)
         assert_stream (astream, 2, 7, "cdekl");
 
         _vte_stream_advance_tail (astream, 3);
-        assert_file (snake->fd, "ABC#DEK#GHI#");
+        assert_file (snake->fd, "____DEK#GHI#");
         assert_snake (snake, 1, 4, 12, "DEK#GHI#");
         assert_boa (boa, 3, 9, "dekghi");
         assert_stream (astream, 3, 7, "dekl");
 
         append (astream, "m");
-        assert_file (snake->fd, "ABC#DEK#GHI#");
+        assert_file (snake->fd, "____DEK#GHI#");
         assert_snake (snake, 1, 4, 12, "DEK#GHI#");
         assert_boa (boa, 3, 9, "dekghi");
         assert_stream (astream, 3, 8, "deklm");
@@ -1230,14 +1339,14 @@ test_stream (void)
          * but not in underlying layers (due to a previous truncate).
          * Nothing special. */
         _vte_stream_advance_tail (astream, 7);
-        assert_file (snake->fd, "ABC#DEK#GHI#");
+        assert_file (snake->fd, "________GHI#");
         assert_snake (snake, 1, 8, 12, "GHI#");
         assert_boa (boa, 6, 9, "ghi");
         assert_stream (astream, 7, 8, "m");
 
         /* Tail reaches head. Still nothing special. */
         _vte_stream_advance_tail (astream, 8);
-        assert_file (snake->fd, "ABC#DEK#GHI#");
+        assert_file (snake->fd, "________GHI#");
         assert_snake (snake, 1, 8, 12, "GHI#");
         assert_boa (boa, 6, 9, "ghi");
         assert_stream (astream, 8, 8, "");
@@ -1277,14 +1386,14 @@ test_stream (void)
         assert_stream (astream, 16, 24, "vwxyzabc");
 
         _vte_stream_advance_tail (astream, 21);
-        assert_file (snake->fd, "UVW#XYZ#ABC#");
+        assert_file (snake->fd, "________ABC#");
         assert_snake (snake, 1, 28, 32, "ABC#");
         assert_boa (boa, 21, 24, "abc");
         assert_stream (astream, 21, 24, "abc");
 
         /* State 2 */
         append (astream, "def");
-        assert_file (snake->fd, "DEF#XYZ#ABC#");
+        assert_file (snake->fd, "DEF#____ABC#");
         assert_snake (snake, 2, 28, 36, "ABC#DEF#");
         assert_boa (boa, 21, 27, "abcdef");
         assert_stream (astream, 21, 27, "abcdef");
@@ -1304,7 +1413,7 @@ test_stream (void)
 
         /* State 4 */
         _vte_stream_advance_tail (astream, 24);
-        assert_file (snake->fd, "DEF#GHI#ABC#JKL#");
+        assert_file (snake->fd, "DEF#GHI#____JKL#");
         assert_snake (snake, 4, 32, 44, "DEF#GHI#JKL#");
         assert_boa (boa, 24, 33, "defghijkl");
         assert_stream (astream, 24, 33, "defghijkl");
