refactored write_seismograms
moved data output code to subroutine