Question: Did a search on google and here
[an error 3013 thrown when writing a file Adobe AIR](https://stackoverflow.com/questions/8588493/an-error-3013-thrown-when-writing-a-file-adobe-air)
but haven't found a solution yet

Using the Filestream class to simply open and write a file to the ApplicationStorage directory

This works fine on Mac-OSX. But when in Windows I get the following error 

```
Error: Error #3013: File or directory is in use.
    at flash.filesystem::FileStream/open()

```

I've checked permissions both on the actual file and enclosing directory and that doesn't seem to be the problem.

Can anyone suggest a solution or troubleshooting steps?

Answer: 
```
text = re.sub(r'\b(\w+)( \1\b)+', r'\1', text) #remove duplicated words in row

```

The `\b` matches the empty string, but only at the beginning or end of a word.
Non- regex solution using `itertools.groupby`:

```
>>> strs = "this is just is is"
>>> from itertools import groupby
>>> " ".join([k for k,v in groupby(strs.split())])
'this is just is'
>>> strs = "this just so so so nice" 
>>> " ".join([k for k,v in groupby(strs.split())])
'this just so nice'

```