Revert 68f7ae9..dcef7b5

This rolls back to commit 68f7ae9dfe4097977177fed4fccb8ab2c3e41e34.
Revert "Revert 68f7ae9..dcef7b5"

This reverts commit 4e80c0b22d2590aecbd2d6b8c92894514bcbe49a.
Revert 0f3a953..b2c5a6d

This rolls back to commit 0f3a9538e1fb8b9b12f48f4239a9b0ecd67c1943.
changing write call to allow dynamic file list