def getOffsetLength(filename, line_number, line_count):
  """
  Calculates the field offset and length based on line number and count.
  """
  offset = 0
  length = 0
  with open(filename, 'r') as f:
    for line in f:
      if line_number > 1:
        offset += len(line)
        line_number -= 1
      elif line_count > 0:
        length += len(line)
        line_count -= 1
      else:
        break
  return offset, length