find why in this code: import tkinter as tk
from tkinter import filedialog
import struct

class Application(tk.Frame):
    header_size = 16
    def __init__(self, master):
        super().__init__(master)
        self.master = master
        self.filename = ''
        self.ccspackets = []
        self.initUI()

    def initUI(self):
        menubar = tk.Menu(self.master)
        filemenu = tk.Menu(menubar, tearoff=False)
        filemenu.add_command(label='Open', command=self.opendialog)
        menubar.add_cascade(menu=filemenu, label='File')
        self.master.config(menu=menubar)

        self.table = tk.Frame(self.master)
        self.table.pack(fill=tk.BOTH, expand=True)

        tk.Label(self.table, text='Packet ID').grid(row=0, column=0, padx=10, pady=5)
        tk.Label(self.table, text='Secondary Header').grid(row=0, column=1, padx=10, pady=5)
        tk.Label(self.table, text='Payload').grid(row=0, column=2, padx=10, pady=5)

    def opendialog(self):
        self.filename = filedialog.askopenfilename(defaultextension='.txt', filetypes=[('Text Files', '.txt'), ('All Files', '.*')])
        if self.filename == '':
            return
        self.process_file()

    def process_file(self):
        with open(self.filename, 'rb') as f:
            # Read the entire file contents as bytes
            file_contents = f.read()
    
            # Split the file contents into individual packets
            packet_delimiter = b'\x03' # CCSDS packet delimiter
            packets = file_contents.split(packet_delimiter)
    
            # Process each packet separately
            for index, packet in enumerate(packets):
                # Decode the packet contents using the CCSDS packet header size and the UTF-8 encoding
                if len(packet) > 0:
                    # Determine the packet header size by scanning for the packet version number field
                    header_size = 0
                    for i in range(len(packet)):
                        if packet[i] & 0xF0 == 0x40:
                            header_size = i + 7 # Add 7 bytes to include the packet sequence count and packet data length fields
                            break
                        
                    print("header size, Packet: ",header_size , packet)   
                    
                    if header_size >= 5 and len(packet) >= header_size:
                        packet_data = struct.unpack('>HHB', packet[:header_size]) # Unpack the packet ID, packet sequence count, and secondary header fields from the packet header
                        packet_id = packet_data[0]
                        packet_sequence_count = packet_data[1]
                        secondary_header = packet_data[2:]
    
                        # Create a table row for the packet
                        row = tk.Frame(self.table)
                        row.pack(fill=tk.X, padx=5, pady=5)
    
                        tk.Label(row, text=packet_id).grid(row=0, column=0, padx=10, pady=5)
                        tk.Label(row, text=packet_sequence_count).grid(row=0, column=1, padx=10, pady=5)
                        tk.Label(row, text=' '.join([hex(b) for b in secondary_header])).grid(row=0, column=2, padx=10, pady=5)
                        tk.Label(row, text=packet[header_size:]).grid(row=0, column=3, padx=10, pady=5)
                    
root = tk.Tk()
root.geometry('800x600')
app = Application(root)
root.mainloop()