import sys
import cProfile

from . import AsciiData, BinaryData

def parsefile(name):
    with open(name) as infile:
        if name.endswith('.asc'):
            data = AsciiData(infile.read())
        else:
            data = BinaryData(infile.read())
    counter = 0
    for packet in data.packets():
        counter += 1
    print(counter)

def main():
    for filename in sys.argv[1:]:
        parsefile(filename)

if __name__ == '__main__':
    cProfile.run('main()', 'main.profile')

@@ -7,24 +7,8 @@
  sys
-%0Aimport cProfile
 %0A%0Afr
@@ -81,16 +81,22 @@
 pen(name
+, 'rb'
 ) as inf
@@ -308,16 +308,38 @@
 er += 1%0A
+        print(packet)%0A
     prin
@@ -460,43 +460,11 @@
     
-cProfile.run('main()', 'main.profile'
+main(
 )%0A

Remove cProfile inclusion, always read file as binary