File output support

Add support for file writing