Showing what a file pointer reads

Files are read by moving a file pointer to a given start position and reading n characters from there until an end position is reached. Unfortunately, these positions are numbers and they tell nothing about the semantics or the words we would like to access. This can be confusing as we can't easily and reliably determine where we are within a file unless we spend a lot of time on adjusting the numbers and looking at the output. Most often we prefer to read the entire file and then use different techniques to extract the content we are interested in. While this works, it is wasteful, because we have to load the entire content in memory, where we were interested only in a small portion of it. If we had large files with text, we would need to read them by character or by line to reduce the memory requirements. We could then check whether a given line contains our search phrase, but we still have to repeat this many times even if we knew the structure of the file in advance.

When we look at content, we can quickly filter out the irrelevant and point to the most valuable. We know that it is at the start/middle/end of a given line, which is itself in a given paragraph. Because we see the entire content upfront and can easily scan it, we don't have to consider positions or number of characters as mixing semantics with numerics can only reduce our understanding. This means that we need some form of a hint to tell us visually where we are within a file.

Below you can visually observe a sample file and adjust the pointer position and the number of characters to highlight what would be read from it. By default, the entire content has been marked for reading.

Ornare tellus est purus eget a risus quam odio nonummy dis lacinia iaculis nulla nascetur justo ante morbi pellentesque porta dolor. Mauris class nascetur congue sem lacus, bibendum ligula morbi cubilia non. Id Rhoncus cubilia fringilla sit lobortis ornare malesuada blandit. Nulla. Semper viverra hendrerit class consequat suscipit at. Taciti, felis tortor enim. Montes augue ridiculus imperdiet vel lectus. Sem semper, dignissim dapibus sem nostra urna pulvinar natoque tempus quis fringilla non erat. Eu dictum. Amet per sagittis Imperdiet. Quisque leo. Dictum interdum gravida sapien tempus dui. Auctor. Etiam massa placerat facilisis nibh. Primis facilisi arcu torquent ultricies leo eu. Montes nam curabitur non pharetra facilisis penatibus facilisi tristique ridiculus. Pellentesque hymenaeos ac Gravida semper lacus nonummy pulvinar enim sagittis libero tincidunt nullam nulla sociosqu. Turpis et cum accumsan convallis pede nascetur viverra hac cum mauris vitae eu non laoreet eros metus elementum venenatis. Per parturient a suscipit nonummy justo, nisi ac rhoncus, cras nullam elit mauris bibendum aliquam Consectetuer libero nullam suspendisse.

Now instead of reading the entire file, we could use the two variables to get only the portion we need. There is much less confusion about the result.