pgm 22.7 run length encoding: files open and close