diff --git a/src/main/java/eu/simstadt/regionchooser/RegionChooserCLI.java b/src/main/java/eu/simstadt/regionchooser/RegionChooserCLI.java
index 5bee332f1ff943ab071e3a6fc45bc0c1439831b3..e54f6d6ddff9b8b784ae493e4ca3c25856546fac 100644
--- a/src/main/java/eu/simstadt/regionchooser/RegionChooserCLI.java
+++ b/src/main/java/eu/simstadt/regionchooser/RegionChooserCLI.java
@@ -19,7 +19,7 @@
 /**
  * Command Line Interface for RegionChooser. Could be useful to extract large regions on server, or automate the process
  * from batch/python scripts.
- * 
+ *
  */
 
 // Usage: region_chooser [-hlV] [-e=31467] -o=output.gml -w=polygon.wkt -i=input.
@@ -109,6 +109,7 @@ public Integer call() throws Exception {
 			logInfo("CityGML written to stdout.");
 			PrintWriter stdOut = spec.commandLine().getOut();
 			count = RegionExtractor.selectRegionDirectlyFromCityGML(wktPolygon, localCRS.toString(), stdOut, citygmls);
+			stdOut.flush(); // To make sure the footer is written too.
 		} else {
 			try (BufferedWriter gmlWriter = Files.newBufferedWriter(outputCityGML)) {
 				count = RegionExtractor.selectRegionDirectlyFromCityGML(wktPolygon, localCRS.toString(), gmlWriter,
diff --git a/src/test/java/eu/simstadt/regionchooser/RegionChooserCLITests.java b/src/test/java/eu/simstadt/regionchooser/RegionChooserCLITests.java
index b4d3b5f2670615929f5d299e7a488df66030e9ca..1d6465d351fe686f9a5c5adfb879983315d9c34d 100644
--- a/src/test/java/eu/simstadt/regionchooser/RegionChooserCLITests.java
+++ b/src/test/java/eu/simstadt/regionchooser/RegionChooserCLITests.java
@@ -67,8 +67,6 @@ void testExtractRegionFromTwoCitygmls() throws IOException {
 			wkt.write(wktPolygon);
 		}
 		assertFalse(Files.exists(outGML));
-		//		originalOut.println("--input=" + citygml1 + "," + citygml2 + " " +
-		//				"--output=" + outGML + " " + "--wkt=" + inWKT + " " + "--epsg=31463" + " " + "--local");
 		new CommandLine(new RegionChooserCLI()).execute("--input=" + citygml1 + "," + citygml2, "--output=" + outGML,
 				"--wkt=" + inWKT, "--epsg=31463", "--local");
 
@@ -126,7 +124,8 @@ void testExtractRegionWithStandardInputAndStandardOutput() throws IOException {
 		assertTrue(err.toString().contains(expectedLog), err.toString() + " should contain " + expectedLog);
 		String expectedBuilding = "uuid_0547df65-ae80-459e-bb15-c839c1a2e566";
 		assertTrue(out.toString().contains(expectedBuilding), out.toString() + " should contain " + expectedBuilding);
-		//FIXME: Footer isn't here, and I don't know why... Should stdout be flushed, closed?
+		String expectedFooter = "</CityModel>";
+		assertTrue(out.toString().contains(expectedFooter), out.toString() + " should contain " + expectedFooter);
 		assertFalse(Files.exists(noOutput));
 	}