Replace deprecated `print` statement with function