improve text display during printFile, add closing commands after main loop