Python Forum
Accept Multiple Lines of Input into a User Created File
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accept Multiple Lines of Input into a User Created File
The problem starts when, from the terminal, as an example, the user cuts and pastes the following:


When I open the user created file I want to see, as a column:


However, only the first line is accepted into the file. I know I'm using raw_input and it only accepts a single how can I use the code for a user created file and somehow get multiple lines into that file?

I tried sys.stdin as well as trying to open targetfile as f but multi-line input won't get into the user created file.
There are no traceback errors.

import os
#import sys

#user creates a file name
targetfile = raw_input('Enter Subject of email here: ')

things_list =

#if user enters input on multiple lines script doesn't send input to targetfilefound, it doesnt quit when type done either
things = raw_input("Enter things, then type 'done' on its own line to quit: \n")

while True:
targetfilefound = open(targetfile , 'w')
while things != "done":
things = raw_input("")
things_list = ''.join(things_list)

except KeyboardInterrupt:

Possibly Related Threads…
Thread Author Replies Views Last Post
  Split Characters As Lines in File quest_ 3 218 Dec-28-2020, 09:31 AM
Last Post: quest_
  code to read files in folders and transfer the file name, type, date created to excel Divya577 0 119 Dec-06-2020, 04:14 PM
Last Post: Divya577
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 222 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes
  Find lines from one file in another tester_V 8 387 Nov-15-2020, 03:29 AM
Last Post: tester_V
  Repeating lines of code by an input Josh_Albanos 3 451 Oct-15-2020, 01:04 AM
Last Post: deanhystad
  user input for multi-dimentional list without a prior iteration using input() Parshaw 6 446 Sep-22-2020, 04:46 PM
Last Post: Parshaw
  How to time a user's input Tbot1000 2 335 Aug-31-2020, 09:39 PM
Last Post: Larz60+
  converting user input to float troubles RecklessTechGuy 3 456 Aug-17-2020, 12:41 PM
Last Post: deanhystad
  Iterate 2 large text files across lines and replace lines in second file medatib531 13 760 Aug-10-2020, 11:01 PM
Last Post: medatib531
  How to assign input file name as logger name Mekala 5 468 Aug-05-2020, 12:54 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020