Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7955855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:48:56+00:00 2026-06-04T03:48:56+00:00

I am trying to write three separate line in a text document based on

  • 0

I am trying to write three separate line in a text document based on input obtained from a dialogue window. I am sure this is a simple fix but I can’t seem to write the three lines as separate lines. Would someone mind telling me what’s wrong with this bit of code?

file = open('file.txt', 'wb') 
file.write('input1')
file.write('input2')
file.write('input3')

The inputs should be on different lines but instead they come out as:

input1input2input3

Instead of:

input1
input2
input3
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:48:57+00:00Added an answer on June 4, 2026 at 3:48 am

    Try this:

    file = open('file.txt', 'wb')
    file.write('input1\n')
    file.write('input2\n')
    file.write('input3\n')
    

    You are appending the newline character '\n' to advance to the next line.

    If you use the with construct, it will automatically close the file for you:

    with open('file.txt', 'wb') as file:
       file.write('input1\n')
       file.write('input2\n')
       file.write('input3\n')
    

    Also, consider using a different variable name in place of file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write data from three txt files in csv file. three
I have three fields, namely Number1 Number2 Time I am trying to write a
I have three lists of lists, and I'm trying to write a generator function
I am trying to write a powershell script that will take in a text
I'm trying to write a function that does something like this: >>> Give-me the
I'm trying to write Linq-To-SQL queries in LinqPad to help migrate users from old
So I have a text file with comma separated numbers, I'm trying to write
I'm trying to digitally read all separate 8 sensors from a QTRA 8-sensor board:
Im trying to write a simple program that will take 2 multi line inputs
I am trying to figure out how to rewrite URLs from something like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.