write multiple records per domain
shift makelines to library
empty_flag to not write empty data