title: Using Pandas to write file creates blank lines
body: <p>I am using the pandas library to write the contents of a mysql database to a csv file.</p>
  
  <p>But when I write the CSV, every other line is blank:</p>
  
  <p><a href="https://i.stack.imgur.com/1BPI2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1BPI2.png" alt="blank lines in csv"></a></p>
  
  <p>Also, it's printing line numbers to the left that I do not want. The first column should be 'Account Number'.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>destination = 'output_file.txt'
  read_sql = """ SELECT LinkedAccountId,ProductName,ItemDescription,ResourceId,UnBlendedCost,UnBlendedRate,Name,Owner,Engagement FROM billing_info ;"""
  fieldnames = ['Account Number', 'Product Name', 'Item Description', 'Resource ID', 'UnBlended Cost', 'UnBlended Rate', 'Name', 'Owner', 'Engagement']
  # Open the file
  f = open(destination, 'w')
  cursor.execute(read_sql)
  while True:
      # Read the data
      df = pd.DataFrame(cursor.fetchmany(1000))
      # We are done if there are no data
      if len(df) == 0:
          break
      # Let's write to the file
      else:
          df.to_csv(f, header=fieldnames)
  </code></pre>
  
  <p>Why is it printing blank lines between the lines with data? How can I get it to create the file without blank lines and without the line number column to the left?</p>