Added function to print ast to user specified file pointer

Users may wish to print AST to file rather than STDOUT, hence this pull request.