added helper function to write to molecule out to file