option to write weights to a specific file