rename print to print_matrix. add error handling. restructure main()