add option to write output into a file

implement #3
Merge pull request #6 from scrm/file_output

add option to write output into a file