diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp
index 959a657478fa..944b564bbe22 100644
--- a/test/yaml-parser.cpp
+++ b/test/yaml-parser.cpp
@@ -48,10 +48,11 @@ protected:
 		if (fd == -1)
 			return false;
 
-		FILE *fh = fdopen(fd, "w");
-		fputs(content.c_str(), fh);
+		int ret = write(fd, content.c_str(), content.size());
+		close(fd);
 
-		fclose(fh);
+		if (ret != static_cast<int>(content.size()))
+			return false;
 
 		return true;
 	}
