def printFile(filename):
  with open(filename,"r") as f:
    count = 0
    for line in f:
      line = line.rstrip("\n")
      count = count + 1
      print("Line #{0:03d}: {1}".format(count, line))

def charCountLine(d, line):
  for c in line:
    # Update the entry for character c
    # Use get with 0 as the second argument so that
    # the dictionary entry is a 0 if it didn't
    # previously exist.
    d[c] = d.get(c, 0) + 1

def charCount(filename):
  d = {}
  with open(filename, "r") as f:
    for line in f:
      charCountLine(d, line)

  return d