Output file option support

Hi,

I have modified some of your code because i need this feature to implement "pre commit" hook. So can you merge this code ?