{"action":"opened","issue":{"url":"https://api.github.com/repos/ipython/ipython/issues/8626","labels_url":"https://api.github.com/repos/ipython/ipython/issues/8626/labels{/name}","comments_url":"https://api.github.com/repos/ipython/ipython/issues/8626/comments","events_url":"https://api.github.com/repos/ipython/ipython/issues/8626/events","html_url":"https://github.com/ipython/ipython/issues/8626","id":94464848,"number":8626,"title":"%%writefile seems to work differently when running ipython vs ipython notebook for a blank line at the end of a file","user":{"login":"donnemartin","id":5458997,"avatar_url":"https://avatars.githubusercontent.com/u/5458997?v=3","gravatar_id":"","url":"https://api.github.com/users/donnemartin","html_url":"https://github.com/donnemartin","followers_url":"https://api.github.com/users/donnemartin/followers","following_url":"https://api.github.com/users/donnemartin/following{/other_user}","gists_url":"https://api.github.com/users/donnemartin/gists{/gist_id}","starred_url":"https://api.github.com/users/donnemartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donnemartin/subscriptions","organizations_url":"https://api.github.com/users/donnemartin/orgs","repos_url":"https://api.github.com/users/donnemartin/repos","events_url":"https://api.github.com/users/donnemartin/events{/privacy}","received_events_url":"https://api.github.com/users/donnemartin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-11T11:44:16Z","updated_at":"2015-07-11T11:44:16Z","closed_at":null,"body":"## IPython\r\n\r\nIf I use the simple snippet below in IPython, which I run from my bash terminal (blank line intentional):\r\n\r\n```\r\n%%writefile foo.py\r\nprint('hello world')\r\n\r\n```\r\n\r\nI get the expected blank line at the end of the file foo.py which is helpful for some tools and for PEP-8 compliance.\r\n\r\n## IPython Notebook\r\n\r\nIf I use the same code in an IPython Notebook cell and run it, *I do not get the blank line*.\r\n\r\nI would have to do the following in a notebook to get the equivalent foo.py (two blank lines intentional):\r\n\r\n```\r\n%%writefile foo.py\r\nhello world\r\n\r\n\r\n```\r\n\r\nChecking the %%writefile docs didn't turn up an option that might address this.\r\n\r\n## Environment\r\n\r\nI'm running Python 2.7.10 and the following:\r\n\r\n$ pip freeze\r\nbackports.ssl-match-hostname==3.4.0.2\r\ncertifi==2015.4.28\r\nfunctools32==3.2.3.post1\r\ngnureadline==6.3.3\r\nipython==3.2.0\r\nJinja2==2.7.3\r\njsonschema==2.5.1\r\nMarkupSafe==0.23\r\nmatplotlib==1.4.3\r\nmistune==0.6\r\nmock==1.0.1\r\nnose==1.3.7\r\nnumpy==1.9.2\r\npandas==0.16.2\r\nptyprocess==0.5\r\nPygments==2.0.2\r\npyparsing==2.0.3\r\npython-dateutil==2.4.2\r\npytz==2015.4\r\npyzmq==14.7.0\r\nscikit-learn==0.16.1\r\nscipy==0.15.1\r\nseaborn==0.6.0\r\nsix==1.9.0\r\nsympy==0.7.6\r\nterminado==0.5\r\ntornado==4.2\r\nwheel==0.24.0"}}