This library can read and update netrc files, preserving formatting
including comments and whitespace.

Homepage:
https://github.com/geemus/netrc
