def get_last_modified(dir)
# make sure the files to be checked are in the provided directory
files = Dir.new(dir).select { |file| file!= '.' && file!='..' }
# make sure the file has been written to
return nil if (files.size < 1)
# create an array of all the files
files = files.collect { |file| File.join(dir , file) }
# sort array by last modified
files = files.sort { |a,b| File.mtime(b)<=>File.mtime(a) }
# return the last modified file
return files.first
end