title: How to read one line at a time by using pyserial
body: <p>I'm facing problem while I'm trying read data from COM port I don't know what is the problem.. here is the code which I'm using to send and receive data through com port.The com port is connected to STM32 board which sends data to be displayed to com port.. I'm appending '\n' at the end of string which is to be displayed. so here is the code  </p>
  
  <pre><code>import serial
  
  ser.port = "COM4"
  ser.baudrate = 9600
  ser.bytesize = serial.EIGHTBITS #number of bits per bytes
  ser.parity = serial.PARITY_NONE #set parity check: no parity
  ser.stopbits = serial.STOPBITS_ONE #number of stop bits
  ser.isOpen()
  
  print 'Enter your commands below.\r\nInsert "exit" to leave the application.'
  
  while 1:
      input = raw_input()
      if input == 'exit':
          ser.close()
          exit()
      else:
          ser.write(input.encode('ascii')+'\r')
          out = ''
  
          while ser.inWaiting() &gt; 0:
              out += ser.readline()
  
              print  out
  </code></pre>
  
  <p>This is the expected output</p>
  
  <pre><code>Different commands offered are as follows: 
  ''dis''                 Displays contact list
  ''crt name number''     To create contact list
  ''del name''                To delete contact details
  ''edt existingName newName number''      To edit contact details
  ''clog''                    To display calllog details
  ''cin''                 Displays only incoming call details
  ''cout''                    Displays only outgoing call details
  ''cmis''                    Displays only missed call details
  ''rvc number''          To receive a call
  ''mkc number''          To make a call
  ''mkc name''                To call from contact list
  ''clogc number''            To call from calllog list
  ''cdel''                    To delete callLog details
  </code></pre>
  
  <p>But I'm getting this
  <a href="http://s15.postimg.org/sg9pvr20r/Untitled.jpg" rel="nofollow">http://s15.postimg.org/sg9pvr20r/Untitled.jpg</a>
  sorry i can't paste total output so I've included screenshot of my output..</p>