use FileUtils methods instead of system call