resolves #907 write to file by default if input is file

- write to file by default if input is file
- use to_file option to control whether file is written instead of in_place
- prevent input file from being overwritten