Handle situation when multiple files are given to the script.
Fix finding realpath taking into account, that filepath can be a symlink.
Fix situations when path to the file doesn't exist and file cannot be created.
Fix some mistakes in previous commit.