DRY writing text file code
validate identifier length