Added possibility to redirect output to given file.