broke apart src/stan/command/print.cpp to the main and functions. added unit tests for next_index and matrix_index. made those two functions safer.
Merge branch 'develop' into feature/issue-280-bin-print-blowing-out-memory
Merge pull request #327 from stan-dev/feature/issue-280-bin-print-blowing-out-memory

Fixed unsafe code in bin/print