def addLineAndNewlineIfNecessary(line, output):
 output.write(line)
 if (len(line) < 1):
  return
 if (not line.endswith('\n')):
  output.write('\n')

def addLineAndNewlineIfNecessary ( line , output ) : output . write ( line ) if ( len ( line ) < 1 ) : return if ( not line . endswith ( '\n' ) ) : output . write ( '\n' )
add the line and if the line does not end with a newline add a newline .