Added optinal file mode.