---
title: "Fixing the Empty Line - Appending To Variables"
url: "https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/fixing-the-empty-line-appending-to-variables.md"
canonical: "https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/fixing-the-empty-line-appending-to-variables/"
tags: []
author: "Roy Osherove"
description: "Lesson 6 of 18 in Automating All the Things with FinalBuilder (Iterations and Variables), 2:45. Free video by Roy Osherove."
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Fixing the Empty Line - Appending To Variables

1. [Courses](https://courses.osherove.com/#courses)
2. [Automating All the Things with FinalBuilder](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/)
3. Iterations and Variables

Lesson 6 of 18

Duration: 2:45 [Watch on YouTube](https://www.youtube.com/watch?v=P-CJqcGcvXg)

## In this lesson

To remove the empty line, Roy Osherove appends the content of each file, with a new line, to a variable named with a v prefix, and replaces the placeholder with that variable once, after the loop. He notes that the script runs a bit slowly, partly because of the virtual machine it runs on and, he guesses, because [FinalBuilder](https://osherove.com/blog/2005/3/12/cooltool-finalbuilder-30-the-ultimate-build-management-and-a.html "[CoolTool] FinalBuilder 3.0 - the ultimate build management and automation tool (osherove.com)") also saves the variables to files, but that it is fast enough for the purpose.

## Transcript

386 words

[\[00:01\]](https://www.youtube.com/watch?v=P-CJqcGcvXg&t=1s) Let's solve the problem from the previous video where we have this empty line. Maybe we're going about this the wrong way. Maybe instead of just appending for each file, maybe we should just accumulate all this text into a new variable and then just replace whatever we had in this line with a new variable and that will be it. So let's see if we how we can actually do that. First let's create a new variable here. We'll call that let's call it v. So that we'll know from this moment on our variables will have these naming conventions.

[\[00:35\]](https://www.youtube.com/watch?v=P-CJqcGcvXg&t=35s) So v slash all inputs and what we're going to do is that for after we read the text while we put stuff inside important contents we're going to look for the word append here and append to a variable the value of important content. So the variable that we have is v all inputs.

[\[01:06\]](https://www.youtube.com/watch?v=P-CJqcGcvXg&t=66s) Let's append to it important contents from that file. We can add a CRLF so a new line every time we append something. So by the end of the iteration we can just have V all inputs and we can just replace things here. So now maybe we don't need to write to the text file here. Let's delete this line here. And let's move the replacement thing here just under the loop after it.

[\[01:39\]](https://www.youtube.com/watch?v=P-CJqcGcvXg&t=99s) And I'm going to replace put stuff here from the file with v all inputs which should contain by the end of this loop iteration the value of all the stuff combined. So, let's save that and run it and see what happens. Running, running, running, running, running. And now we should be able to see what happens.

[\[02:09\]](https://www.youtube.com/watch?v=P-CJqcGcvXg&t=129s) Let's see. New filet txt. Now there is no empty line. We still have all that value. So, another way to work with variables is to hold them and append to them in memory and then use all that stuff. Notice that it's running a bit slow. Part of it is because it's running on a virtual machine on a Mac. On part of it is because the way that FinalBuilder works, it also saves the variables locally to files, I guess. So, it takes a bit more time, but for our purposes, it's definitely fast enough.

## Related

### Also linked in this lesson

#### osherove.com

- [\[CoolTool\] FinalBuilder 3.0 - the ultimate build management and automation tool](https://osherove.com/blog/2005/3/12/cooltool-finalbuilder-30-the-ultimate-build-management-and-a.html)

[Previous lesson Iterating over Files](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/iterating-over-files/) [Next lesson Using the Debugger](https://courses.osherove.com/courses/automating-all-the-things-with-finalbuilder/using-the-debugger/)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
