def extractWholeLine(buf, isFirstLine):
  """
  Return the next complete line of input if available.

  ``buf`` is the accumulated input buffer received from
  decode-978. The goal is to extract complete lines from
  this data and return them as output. ``buf`` is altered
  to reflect the line being removed. We are also careful
  (using ``isFirstLine``) to ensure that all lines are 
  complete lines and that the initial characters we get
  are not sent until the first newline is captured.

  Clients will only be sent complete lines, from beginning
  to end.

  Args:
    buf (list): Current output buffer.
    isFirstLine (bool): True if we have not output
      any data. This is used to throw out any partial
      first line before a newline is received. After 
      the initial trash data is thrown away, this will
      be False for the rest of the run.

  Returns:
    tuple: Tuple containing:

    * String containing a new line to send to clients, or ``None``
      if no line available.
    * Updated version of ``buf`` to reflect any changes.
    * Updated version of ``isFirstLine``. Once set to ``False``
      will remain that way.
  """
  # If we are just starting, wait until the beginning of a 
  # new line.
  if isFirstLine:
    # Have not found our first \n
    idx = buf.find('\n')
    if idx == -1:
      # Still don't have our first \n
      return None, buf, True

    # Get rid of any partial line
    if len(buf) == idx + 1:
      buf = ''
    else:
      buf = buf[idx + 1:]

  # See if we have an entire line
  idx = buf.find('\n')
  if idx == -1:
    return None, buf, False

  line = buf[:idx + 1]
  if len(buf) == idx + 1:
    buf = ''
  else:
    buf = buf[idx + 1:]

  return line, buf, False