code: def read_record(fp, first_line=None):
      
  
      if first_line is None:
          first_line = fp.readline()
  
      if not first_line:
          raise EOFError()
  
      match = _START.match(first_line)
      if not match:
          raise Exception('Bad start of message', first_line)
  
      type = match.group(1)
      message = Message(type)
  
      while True:
          row = fp.readline()
  
          match = _MULTILINE_FIELD.match(row)
          if match:
              key = match.group(1)
              val = ""
              while row:
                  pos = fp.tell()
                  row = fp.readline()
                  if row[0] in '.':
                      break
                  elif row[0] in '{}':
                      fp.seek(pos)  # put the line back
                      break
                  val += row
              message.contents.append((key, val, True))
              continue
  
          match = _FIELD.match(row)
          if match:
              key, val = match.group(1), match.group(2)
              message.contents.append((key, val, False))
              continue
  
          match = _START.match(row)
          if match:
              message.append(read_record(fp, row))
              continue
  
          if row[0] == '}':
              break
  
          raise Exception('Bad line', row)
  
      return message
docs: Read a record from a file of AMOS messages
  
      On success returns a Message object
      On end of file raises EOFError