The problem with this being that you have to substr twice for every comparison, which, when the file becomes large, is substatially more time consuming than the ST or GRT which does a substr for each line only. He explains that in this Unix Review Column.
Who is Kayser Söze? Code is (almost) always untested.