Refactor #write_sample_configuration.

Small refactor of Pear::Configuration#write_sample_configuration. Three
methods were extracted improving primarily readability but also
maintainability.
Print message only if commands executed finished successfully.