pack_table (KirbyBase::KBEngine)

    # File lib/kirbybase.rb, line 1653
        def pack_table(table)
            with_write_lock(table.name) do
                fptr = open(table.filename, 'r')
                new_fptr = open(table.filename+'temp', 'w')

                line = fptr.readline.chomp
                # Reset the delete counter in the header rec to 0.

                if line[0..0] == 'Z'
                    header_rec = unencrypt_str(line[1..-1]).split('|')
                    header_rec[1] = '000000'
                    new_fptr.write('Z' + encrypt_str(header_rec.join('|')) +
                     "\n")
                else
                    header_rec = line.split('|')
                    header_rec[1] = '000000'
                    new_fptr.write(header_rec.join('|') + "\n")
                end

                lines_deleted = 0

                begin
                    while true
                        line = fptr.readline

                        if table.encrypted?
                            temp_line = unencrypt_str(line)
                        else
                            temp_line = line
                        end

                        if temp_line.strip == ''
                            lines_deleted += 1
                        else
                            new_fptr.write(line)
                        end
                    end
                # Here's how we break out of the loop...

                rescue EOFError
                end

                # Close the table and release the write lock.

                fptr.close
                new_fptr.close
                File.delete(table.filename)
                FileUtils.mv(table.filename+'temp', table.filename)

                # Return the number of deleted records that were removed.

                return lines_deleted
            end
        end