title: print() without newline does not work when reading from stdin
body: <p>I started writing a primitive ssh-like program for practice's sake. I was starting to check if the commands would be delivered properly before implementing any further functionality, so i just wrote a server which receives messages from the client and prints them in it's own console window, but before it receives a message, it sends a prefix to the client, which the client prints so it's right before ( to the left of) the user input. For the prefix to be to the left of the input i tried to use <code>print( ... , end='')</code>, but that seems to break the whole thing, and the prefix then does not print at all, as opposed to the solution where the prefix is printed the line before, where the program works perfectly fine besides that little problem.</p>
  
  <p>TL;DR :</p>
  
  <p><em>this (where s is the socket)</em></p>
  
  <pre><code>for n, line in enumerate(sys.stdin):
      prefix = s.recv(16)
      print(prefix.decode('utf-8'), end='')
      s.send(line.encode('utf-8'))
  </code></pre>
  
  <p>code does not print the received prefix at all, only after closing the program with CTRL + D or CTRL + C as shown below:</p>
  
  <pre><code>czyngis@czyngis-mint:[directory censored]$ python3 cmd_client.py -t fc70:6872:4c6:10ae:71c::1 -p 9999
  target: fc70:6872:4c6:10ae:71c::1 | port: 9999
  connection established with: fc70:6872:4c6:10ae:71c::1 on port: 9999
  
  first code sample  //&lt; user input
  does not work :(   //&lt; user input
  ^C&lt;#CMD:&gt;&lt;#CMD:&gt;&lt;#CMD:&gt;Traceback (most recent call last):
    File "cmd_client.py", line 26, in &lt;module&gt;
      for n, line in enumerate(sys.stdin):
  KeyboardInterrupt
  </code></pre>
  
  <p>and <em>this ( where s is also the socket )</em></p>
  
  <pre><code>for n, line in enumerate(sys.stdin):
      prefix = s.recv(16)
      print(prefix.decode('utf-8'))
      s.send(line.encode('utf-8'))
  </code></pre>
  
  <p>code does print the prefix, but in the previous line, as shown below:</p>
  
  <pre><code>czyngis@czyngis-mint:[directory censored]$ python3 cmd_client.py -t fc70:6872:4c6:10ae:71c::1 -p 9999
  target: fc70:6872:4c6:10ae:71c::1 | port: 9999
  connection established with: fc70:6872:4c6:10ae:71c::1 on port: 9999
  
  &lt;#CMD:&gt;
  second code sample
  &lt;#CMD:&gt;
  works, but not quite :(^CTraceback (most recent call last):
    File "cmd_client.py", line 26, in &lt;module&gt;
      for n, line in enumerate(sys.stdin):
  KeyboardInterrupt
  </code></pre>
  
  <p>Thank You for any help in advance.</p>