Used UsageError instead of print. Passed the IndexError exception without notice.
Added --notebook option and load of output_notebook function only once.